Question: MIPSMisc.asm .data # Put Global Data here N: .word 5 # loop count X: .word 2, 4, 6, 8, 10 SUM: .word 0 # location

 MIPSMisc.asm .data # Put Global Data here N: .word 5 #

loop count X: .word 2, 4, 6, 8, 10 SUM: .word 0

MIPSMisc.asm

.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

I. data # Put Global Data here N: . X: .word 2, 4, 6, 8, 10 SUM: word 0 # location of the final surn word 5 # loop count str: .a3ciiz "The sum of the array 13 = " . text # Put program here globl main # globally define 'main' main: 1w $30, N # load 1?op counter int? $30 la $t0, X # load the address of X into $t0 and $31, $31, $zero # clear $31 aka temp 3um loop: 1w $t1, 0(StO) # load the next value of x add $31, $31, $t1 # add it t the running sum addi $t0, $t0, 4 # increment to the next address addi $30, $30, -1 # decrement the loop counter bne $0, $30, loop # loop back until complete sw $31, SUM # 3tore the final total li $v0, 10 # 3y3call to exit cleanly from main only syscall # this ends execution end I. data # Put Global Data here N: . X: .word 2, 4, 6, 8, 10 SUM: word 0 # location of the final surn word 5 # loop count str: .a3ciiz "The sum of the array 13 = " . text # Put program here globl main # globally define 'main' main: 1w $30, N # load 1?op counter int? $30 la $t0, X # load the address of X into $t0 and $31, $31, $zero # clear $31 aka temp 3um loop: 1w $t1, 0(StO) # load the next value of x add $31, $31, $t1 # add it t the running sum addi $t0, $t0, 4 # increment to the next address addi $30, $30, -1 # decrement the loop counter bne $0, $30, loop # loop back until complete sw $31, SUM # 3tore the final total li $v0, 10 # 3y3call to exit cleanly from main only syscall # this ends execution end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!