Carson Wood
Carson Wood

Reputation: 1324

Opcode and funct code in MIPs Assembly

My professor takes forever to answer emails, reasonably so since its Saturday, so I just wanted to ask here instead.

I read here that the funct code defines what the function being used is (add, sub, etc) and the opcode defines the format (R,I,J)...but then how does the I format know what funct to use if it doesn't have a funct part? It has opcode,rs,rt,immediate. I thought immediate would just be like a # like the addi, $t0, $s0, 1 for example.

Can anybody clarify what opcode and funct do exactly? I'm fairly new to Assembly.

Thanks.

Upvotes: 1

Views: 8594

Answers (1)

Michael
Michael

Reputation: 58507

The R-type instructions share the same opcode (000000), so an additional 6 bits (the function bits) are used to separate the different instructions.

I-type instruction don't have any leftover space for the function bits, so instead they all have different opcodes.

Every instruction must be uniquely identifiable, and for some instructions that identifier is 6 bits, and for some it's 12 bits. It's just how the instruction set designers chose to divide the possible encodings among the different instructions.

Upvotes: 4

Related Questions