Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For these programming exercises, use only those instructions that have been disc

ID: 3698836 • Letter: F

Question

For these programming exercises, use only those instructions that have been discussed so far in these notes:

USING MIPS Simulator

Declare three arrays, each of the same size:

Initialize a base register for each array (use the la instruction.) Now implement a loop that adds corresponding elements in the first two arrays and stores the result in the corresponding element of theresult array. Do this by moving each of the three base registers to its next array element after each addition.

Basic Instructions add div mflo slt, slti addi divu mult sltu, sltiu addiu j multu sra addu lb nor srl and lbu or sub andi lh ori subu beq lhu sb sw bgez lui sh xor bltz lw sll xori bne mfhi PseudoInstructions la lw nop li move sw

Explanation / Answer

.data size: .word 7 array1: .word -30, -23, 56, -43, 72, -18, 71 array2: .word 45, 23, 21, -23, -82, 0, 69 result: .word 0, 0, 0, 0, 0, 0, 0 .text lw $t0, size la $s0, array1 la $s1, array2 la $s2, result li $t1, 0 WHILE: bge $t1, $t0, END sll $t2, $t1, 2 add $t2, $s0, $t2 lw $t2, 0($t2) sll $t3, $t1, 2 add $t3, $t3, $s1 lw $t3, 0($t3) add $t4, $t2, $t3 sll $t5, $t1, 2 add $t5, $t5, $s2 sw $t4, 0($t5) addi $t1, $t1, 1 j WHILE END: