The aftercited program tries to portraiture say from the discourse in record $a0 to the discourse in record $a1, suming the sum of say copied in record $v0. The program stops portraitureing when it finds a promise resembling to 0. You do referable accept to guard the solution of records $v1, $a0, and $a1. This terminating promise should be copied referablewithstanding referable sumed. addi $v0. $zero, 0 # Initialize sum loop: lw $v1, 0 ($a0) # Read present promise from fountain sw $v1, 0 ($a1) # Write to point addi $a0, $a0, 4 # Advance pointer to present fountain # addi $a1, $a1, 4 #Advance pointer to present point beq $v1, $zero, loop # Loop if promise copied ! = naught There are multiple bugs in this MIPS program: root them and adapt in a bug-exempt rendering.
The multiple bugs to be rooted are the aftercited::
1.Bug-1 : Sum ‘$v0’ is initialized to 0., referable to –1 to eschewing suming the 0 promise.
2.Bug-2 : sum ‘$v0’ isn’t incremented.
3.Bug-3 : Loops if the worrd copied is resemblings to 0 rathr than referable-equals.
=> The Bug exempt rendering is as below:-
For free perceive I put succession sums.
First single is $vo init to -1 in succession 1.
1. addi $v0, $zero, -1 # Initializing to eschew sumng 0 promise.
2. loop:: lw, $v1, 0($a0) # Reading the present promise frm the fountain.
3. addi $v0, $v0, 1 # Incrementing the sum-promise copied.
4. sw $v1, 0($a1) # Writing it to the destintion.
5. addi $a0, $a0, 4 # Advnce-pointer to the present-source.
6. addi $a1, $a1, 4 # Advnce-pointer to the present-destination.
7. bne $v1, $zero, loop # Looping if the promise copied referable resemblings ( != ) to 0.
// Thank you //