Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Describe the concept of diversity.

Answered: 1 week ago

Question

3. What are potential solutions?

Answered: 1 week ago