0
votes

Im reviewing a problem where given a MIPS instruction, I have to write down the decimal value of the 4 fields corresponding to the opcode, rs, rt, and the function. I understand that the decimal value for rs and rt are just the decimal representations of the registers (i.e, $s0 is 16) but how could i figure out the 16 bit function code?

2
Just convert the 16 bit binary number (or the 4 digit hex number) to decimal. - alf
the binary isnt given, will edit the q with a picture of the problem. - jfisk

2 Answers

0
votes

You can not determine that value.You need to be given that values.Each function code does different things,there are many instruction that has the same format.

0
votes

Every instruction has its own opcode & function code. You can find the opcodes here, for example:

https://www.student.cs.uwaterloo.ca/~isg/res/mips/opcodes

For example, addi is 001000 in binary for the first 6 bytes (the opcode), followed by 2x5 bytes for the registers, followed by 16 bytes for the immediate value

add is 000000 (opcode), followed by 3x5 bytes for the registers, 00000 for shift amount (not used for this instruction), followed by 100000 for the function code.