Name: Box: Date:

## HW6 solution

1. (22 points) As discussed on pages 140–141 (Section 2.12 "Assembler"), pseudoinstructions are not part of the MIPS instruction set, but often appear in MIPS programs. For each pseudoinstruction in the following table, produce a minimal sequence of actual MIPS instructions to accomplish the same thing.

You may need to use $at for some of the sequences. In the following tables, BIG refers to a specific number that requires 32 bits to represent and SMALL to a number that can fit in 16 bits. You may need to refer to the most-significant/least-significant half of BIG in your answers. Unless otherwise specified assume all integers are signed. Pseudoinstruction What it accomplishes Actual instructions move$t0, $t1 $t0 = $t1 add$t0, $t1,$0
clear $t0 $t0 = 0 add $t0,$0, $0 li$t0, SMALL $t0 = SMALL addi$t0, $0, SMALL li$t1, BIG $t1 =big lui$at mshBIG
ori $t1,$at, lshBIG
beq $t0, SMALL, L if ($t0 == SMALL) goto L addi $at,$0, SML
beq $at,$t0, L
beq $t1, BIG, L if ($t1 == big) goto L lui $at, mshBIG ori$at $at lshBIG beq$at $t1 L Pseudoinstruction What it accomplishes Actual instructions ble$t3, $t5, L if ($t3 <= $t5) goto L slt$at, $t5,$t3
beq $at,$0, L
bgt $t3,$t5, L if ($t3 >$t5) goto L slt $at,$t5, $t3 bne$at, $0, L bge$t3, $t5, L if ($t3 >= $t5) goto L slt$at, $t3,$t5
beq $at,$0, L
addi $t1,$t2, BIG $t1 =$t2 + big lui $at, mshBIG ori$at, $at, lshBIG add$t1, $t2,$at
lw $t5, BIG($t2) $t5 = Memory at address$t2 + big lui $at, mshBIG ori$at, $at, lshBIG add$at, $at,$t2
lw $t5, 0($at)
or, if the assembler can account for sign-extension of the LSH:
lui $at, mshBIG add$at, $at,$t2
lw $t5, lshBIG($at)