How to know MIPS-instruction format R, I or J

5.6k views Asked by At

How to know if the opcode of the MIPS instruction is Register, Imidiate or Jump ? Given this table from the book, but is there any way to define the format of the opcode ?

https://i.stack.imgur.com/iRn3P.png

1

There are 1 answers

3
Seva Alekseyev On BEST ANSWER

Take a look at the opcode bits - the most significant 6 bits. In C, if n is the 32-bit command dword, the expression for the opcode is (n >> 26) & 0x3f.

If opcode is 0, then it's a register command.

If it's 2 (j), 3 (jal), or 26 (trap) - it's a jump.

Else immediate.

A cheat sheet of MIPS encoding, including a list of all opcodes, is available here, and probably elsewhere.