For the following MIPS instruction sequence please convert t
For the following MIPS instruction sequence, please convert them into the machine language format. For each field in the instruction format, you can use decimal or hex values. You don’t need to use binary.
leaf_example:
addi $sp, $sp, -4
sw $s0, 0($sp)
add $t0, $a0, $a1
add $t1, $a2, $a3
sub $s0, $t0, $t1
add $v0, $s0, $zero
lw $s0, 0($sp)
addi $sp, $sp, 4
jr $ra
Solution
00400000: 23bdfffc ; <input:0> addi $sp, $sp, -4
00400004: afb00000 ; <input:1> sw $s0, 0($sp)
00400008: 00854020 ; <input:2> add $t0, $a0, $a1
0040000c: 00c74820 ; <input:3> add $t1, $a2, $a3
00400010: 01098022 ; <input:4> sub $s0, $t0, $t1
00400014: 02001020 ; <input:5> add $v0, $s0, $zero
00400018: 8fb00000 ; <input:6> lw $s0, 0($sp)
0040001c: 23bd0004 ; <input:7> addi $sp, $sp, 4
00400020: 03e00008 ; <input:8> jr $ra
