hw1 Soln
hw1 Soln
HW #1 – Due 1/10
1.) Pseudo-instructions (instructions that are not actually part of the MIPS
instruction set) often appear in MIPS programs. This can be for the
convenience of programmer or to make them more readable by humans.
Translate the following pseudo-instructions into the minimal sequence of
actual MIPS instructions that perform the desired function. You may
need to use the $at register to store a temporary value.
li $t1, small
ori $t1, $zero, small
This makes sure that the upper 16-bits of the register are zero. This mirrors what
occurs in a “lui” instruction (upper 16-bits are a constant, lower 16-bits are zero).
3.) Convert the following machine code to assembly (don’t forget to create labels for branch or
jump targets):
Address Instruction Label Assembly
512 000110 01000 00000 0000000000000010 blez $t0, Marker
516 101011 01000 00100 0000000000000000 sw $a0, 0($t0)
520 100011 01000 00100 0000000000000100 lw $a0, 4($t0)
524 001110 00101 01000 0001111101110011 Marker: xori $t0, $a1, 8051
528 000000 00100 00100 00101 00000 100000 add $a1, $a0, $a0