In: Computer Science
Convert the following to machine code and then back to MIPS instructions:
1)
a. addi $s0, $zero, -15
b. slt $t0, $s0, $s1
c. beq $t0, $zero, LEEQ
d. j GRT
Format:
Opcode(6-bit) rs(5-bit) rt(5-bit) immediate(16-bit)
addi $zero $s0 -15
001000 00000 10000 1111111111110001
Hex: 0x2010fff1
---------------------------------------------------------------------------------------------------------------------
Format:
opcode(6-bit) rs(5-bit) rt(5-bit) rd(5-bit) shamt(5-bit) func(6-bit)
slt $s0 $s1 $t0
000000 10000 10001 01000 00000 101010
Hex: 0x02114020
-----------------------------------------------------------------------------------------------------------------------------------------
Here i assume LEEQ label after 'j' instruction
Format:
Opcode(6-bit) rs(5-bit) rt(5-bit) offset(16-bit)
beq $t0 $zero 1(After 1 instruction)
000100 01000 00000 0000000000000001
Hex: 0x11000001
--------------------------------------------------------------------------------------------------------------------
Here i assume GRT label is the start label
Format:
opcode(6-bit) Target(26-bit)
000010 ox00003000(I assume )
000010 00000000000011000000000000>>2(shift 2)
000010 00000000000000110000000000
Hex: 0x08000c00
----------------------------------------------------------------------------------------------------------------------
Note:
GRT:
addi $s0,$0,-15
slt $t0,$s0,$s1
beq $t0,$0,LEEQ
j GRT
LEEQ: