For these programming exercises, use only those instructions that have been disc
ID: 3738174 • Letter: F
Question
For these programming exercises, use only those instructions that have been discussed so far in these notes:
USING MIPS
Evaluate the expression:
Use symbolic addresses x, y, and answer. Assume that the values are small enough so that all results fit into 32 bits. Since load delays are turned on in SPIM be careful what instructions are placed in the load delay slot.
Verify that the program works by using several initial values for x and y. Use x=0, y=1 and x=1, y=0 to start since this will make debugging easy. Then try some other values. As an option, follow the precaution for multiplication, as above.
add lw sll addi mfhi sra addiu mflo srl addu mult sub and multu subu andi nor sw div or xor divu ori xori luiExplanation / Answer
.data x: .word 0 y: .word 1 answer: .word 0 .text lw $t0, x lw $t1, y mult $t0, $t1 mflo $s0 addi $t2, $zero, 17 mult $s0, $t2 mflo $s0 addi $t2, $zero, 12 mult $t0, $t2 mflo $s1 addi $t2, $zero, 6 mult $t1, $t2 mflo $s2 addi $s3, $zero, 12 sub $s4, $s0, $s1 sub $s4, $s4, $s2 add $s4, $s4, $s3 la $t2, answer sw $s4, 0($t2)