Question: arrcp.s ~~~~~~~~~~~~~ .data source: .word 3, 1, 4, 1, 5, 9, 0 dest: .word 0, 0, 0, 0, 0, 0, 0 countmsg: .asciiz values

arrcp.s
~~~~~~~~~~~~~
.data source: .word 3, 1, 4, 1, 5, 9, 0 dest: .word 0, 0, 0, 0, 0, 0, 0 countmsg: .asciiz " values copied. "
.text
main: la $a0,source la $a1,dest
loop: lw $v1, 0($a0) # read next word from source addiu $v0, $v0, 1 # increment count words copied sw $v1, 0($a1) # write to destination addiu $a0, $a0, 1 # advance pointer to next source addiu $a1, $a1, 1 # advance pointer to next dest bne $v1, $zero, loop# loop if word copied not zero
loopend: move $a0,$v0 # $a0
la $a0,countmsg # $a0
li $a0,0x0A # $a0
finish: li $v0, 10 # Exit the program syscall
### The following functions do syscalls in order to print data (integer, string, character) #Note: argument $a0 to syscall has already been set by the CALLEE
puti: li $v0, 1 # specify Print Integer service syscall # Print it jr $ra # Return
puts: li $v0, 4 # specify Print String service syscall # Print it jr $ra # Return
putc: li $v0, 11 # specify Print Character service syscall # Print it jr $ra # Return
(Exercise) Debugging MIPS Debug the loop written in arrcp.s. The program is suppose to copy integers from memory address in $a0 to memory address in $a1, until it reads a zero value. The number of integers copied (up to but not including the zero value) should be returned so stored into $v0 Q1. How many bugs are there? Q2. How do you fix the bug(s)? Q3. What is your strategy to finding the bug(s)? Fix the code so it works in arrcp.s
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
