Question: MIPS assembly instructions 1) What does this program do? What value does the register s1 hold once you run this program? What does s1 represent?
MIPS assembly instructions
1) What does this program do? What value does the register s1 hold once you run this program? What does s1 represent?
-----MIPS Code-----
| .data # Put Global Data here N: .word 5 # loop count X: .word 2, 4, 6, 8, 10 SUM: .word 0 # location of the final sum str: .asciiz "The sum of the array is = " .text # Put program here .globl main # globally define 'main' main: lw $s0, N # load loop counter into $s0 la $t0, X # load the address of X into $t0 and $s1, $s1, $zero # clear $s1 aka temp sum loop: lw $t1, 0($t0) # load the next value of x add $s1, $s1, $t1 # add it to the running sum addi $t0, $t0, 4 # increment to the next address addi $s0, $s0, -1 # decrement the loop counter bne $0, $s0, loop # loop back until complete sw $s1, SUM # store the final total li $v0, 10 # syscall to exit cleanly from main only syscall # this ends execution .end |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
