Question 9.1: Write a MIPS assembly language program for the following pro...
Write a MIPS assembly language program for the following program which adds two arrays x(i) and y(i), each of which has 100 elements.
for i=0; i<100; i++ ; repeat 100 times
y(i) = x(i) + y(i) ; add ith element of the arrays
Assume that the x and y arrays start at locations 4000 and 8000 (decimal).
Learn more on how we answer questions.
andi $3, $3, 0 ; initialize loop counter $3 to 0
andi $2, $2, 0 ; clear register for loop bound
addi $2, $2, 400 ; loop bound
$label: lw $15, 4000($3) ; load x(i) to R15
lw $14, 8000($3) ; load y(i) to R14
add $24, $15, $14 ; x(i) + y(i)
sw $24, 8000($3) ; save new y(i)
addi $3, $3, 4 ; update address register, address= address + 4
bne $3, $2, $label ; check if loop counter=loop bound