2. (7 points) The following program tries to copy words from the address in register $4 to the address in register $5, counting the number of words copied in register $2. The program stops copying when it finds a word equal to 0. You do not have to preserve the contents of registers $3, $4, and $5. This terminating word should be copied but not counted. Loop: lw $3,0($4) # Read next word from source addi SW $2,$2,1 # Increment count of words copied $3,0($5) # Write to destination addi $4,$4,1 addi $5,$5,1 # Advance pointer to next source # Advance pointer to next destination #goto Loop if word copied = zero bne $3,$0, Loop There multiple bugs in this MIPS program. Fix them and turn in a bug-free version of this program.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.4: Program Input Using Cin
Problem 9E
icon
Related questions
Question

no chatgpt, explain in concise detial 

2.
(7 points) The following program tries to copy words from the address in register
$4 to the address in register $5, counting the number of words copied in register
$2. The program stops copying when it finds a word equal to 0. You do not have to
preserve the contents of registers $3, $4, and $5. This terminating word should be
copied but not counted.
Loop:
lw $3,0($4) # Read next word from source
addi
SW
$2,$2,1 # Increment count of words copied
$3,0($5) # Write to destination
addi $4,$4,1
addi $5,$5,1
# Advance pointer to next source
# Advance pointer to next destination
#goto Loop if word copied = zero
bne $3,$0, Loop
There multiple bugs in this MIPS program. Fix them and turn in a bug-free version
of this program.
Transcribed Image Text:2. (7 points) The following program tries to copy words from the address in register $4 to the address in register $5, counting the number of words copied in register $2. The program stops copying when it finds a word equal to 0. You do not have to preserve the contents of registers $3, $4, and $5. This terminating word should be copied but not counted. Loop: lw $3,0($4) # Read next word from source addi SW $2,$2,1 # Increment count of words copied $3,0($5) # Write to destination addi $4,$4,1 addi $5,$5,1 # Advance pointer to next source # Advance pointer to next destination #goto Loop if word copied = zero bne $3,$0, Loop There multiple bugs in this MIPS program. Fix them and turn in a bug-free version of this program.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage