In: Computer Science
3. beq $s0, $s1, LABEL #consider LABEL represents
the 16-bit value 0x00FF
Solution :
MIPS to machine code :
a) add $s0, $s1, $s2 :
For add instruction, Initial special bits are : 000000
The register $s1 can be written as : 10001
The register $s2 can be written as : 10010
The register $s0 can be written as : 10000
The OPCODE for ADD is : 00000 100000
Hence the instruction in binary can be written as :
00000010001100101000000000100000
The instruction in hex can be written as : 0x02328020
b) lw $s0, 15($s1) :
The load word instruction has opcode of : 100011
The register $s1 can be written as : 10001
The register $s0 can be written as : 10000
The offset here is 0x15 : 0000000000010101
So the instruction in binary can be written as :
10001110001100000000000000010101
The instruction in hexadecimal can be written as : 0x8E300015
c) beq $s0, $s1, LABEL :
The beq instruction has opcode as : 000100
The register $s0 can be written as : 10000
The register $s1 can be written as : 10001
The 16 bit offset here is : 0000000011111111
The instruction in binary can be written as :
00010010000100010000000011111111
The instruction in hexadecimal can be written as : 0x121100FF
If you have any doubts, then you can ask in comment section. Thank you.