0
$\begingroup$

I would appreciate some help with this question.

The 32 bit numbers below represent a MIPS instruction. identify the different fields and state which instruction it is. give the assembler source code that can be converted into this instruction.

001000|10001|10010|0000000000001111

I separated the bits and I know the first 6 bits are the opcode and given the opcode it means Addi. The last 16 bits are the immediate value which I have converted to 15. I do need help with the registers and converting the binary into the register number. I have looked everywhere and can not find an explanation. Any help would be appreciated. i know the structure takes this format:

Addi, t,s, 15

$\endgroup$
0
$\begingroup$

You've basically got the answer already: the s register is number 0b10001 = 17, the t register is number 0b10010 = 18.

The instruction is not quite the way you've said it: standard MIPS has the registers in the opposite order, so it's opcode rs rt immediate. The opcode is 0b001000 = 8 = ADDI; rs is 0b10001 = 17 = $s1; rt is 0b10010 = 18 = $s2; the immediate value is 0b0000000000001111 = 15.

(The prefix 0b indicates that the following number is in binary.)

$\endgroup$
  • $\begingroup$ Thank you. i haven't been able to find an information on it. would i need to write $t17? $\endgroup$ – jessie Aug 31 '18 at 20:24
  • $\begingroup$ @jessie For the registers? For e.g. register 17 you can either use $17 or $s1 (its symbolic name). $\endgroup$ – Draconis Aug 31 '18 at 20:30
  • $\begingroup$ is there an efficient way to convert say r17 to its symbolic name $s1? $\endgroup$ – jessie Aug 31 '18 at 20:32
  • $\begingroup$ @jessie Looking it up in a table is the easiest way. This one was the first hit on Google. $\endgroup$ – Draconis Aug 31 '18 at 20:34
  • $\begingroup$ Thank you. this will help with my studies. can i ask if i was to convert the other way say: add r3, r5, r4. Would you know how i would go about converting those registers? would it be as simple as convert say r4 to 0100? $\endgroup$ – jessie Aug 31 '18 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.