Reputation: 11639
I have this question:
Provide the type and hexadecimal representation of following instruction: sw $t1, 32($t2)
So I have this in binary:
101011 01010 01001 0000 0000 0010 0000
43 10 9 32
43 is the op code for store word and .
10 is the register code for $t2
9 is the register code for $t1 .
32 is the address
But how do I then convert this to hexadecimal?
Upvotes: 2
Views: 10876
Reputation: 3613
From what I understand you're running this on MIPS32 architecture. The instructions do produce the binary output you wrote but your decimal representation of the output is incorrect. If the first eight bits produce 32 which is accurate then the next eight bits can not produce a 9. And in some areas you've grouped five bits as apposed to four bits. So the first step would be to group them correctly.
1010 1101 0100 1001 0000 0000 0010 0000
Now the first eight bits produce 32.
The next eight bits produce 0.
The next eight bits produce 73.
And the last eight bits produce 173.
Now you just need the hex representation of each decimal value.
32 in Hex is 20.
0 in Hex is 0.
73 in Hex is 49.
173 in Hex is ad.
Which in Little Endian leaves you with the instruction as
20 00 49 ad
In your case either your binary represetation of the assembly instruction is wrong or your decimal representation of the binary representation is wrong. If you are using MIP32 architecture then your binary is accurate but your decimal is inaccurate.
Upvotes: 2