Reputation: 35
A register $t0
contains value 0x10008040
. Write out the machine code for
the MIPS instruction that loads a word from the main memory at address
0x10008048
, and stores the result in register $s1
. The instruction should make use of register $t0
. Answer as a hexadecimal value for the machine code.
i have come so far in this question
lw $t0, 8($s1)
then i am stack how to do thanks for help.
Upvotes: 1
Views: 11925
Reputation: 846
Actually you have only found the instruction, so it's not ending there from your spec.
Write out the machine code for the MIPS instruction.
lw $s1, 8($t0)
In order to write the machine code for this instruction you need to look at MIPS reference sheet MIPS Reference sheet
If you look at the sheet the lw
has opcode 35 and for $1
is 17 , for $t0
is 8 and offset is 8. Arrange it as following
op rs rt immidiate
35 8 17 8
To binary
100011 01000 10001 0000000000001000
Group as 4 bits
1000 1101 0001 0001 0000 0000 0000 1000
To hexadecimal
0x8D110008
Answer as a hexadecimal value for the machine code.
0x8D110008
Upvotes: 5
Reputation: 2121
Almost got it, but you need to swap the registers. I think that's it, just one instruction.
lw $s1, 8($t0) // $s1 = *($t0 + 8)
Upvotes: 3