Question: ALSO PLEASE EXPLAIN THE FIXED ERRORS PLEASE! arrcpy.s for 1-3 .data source: .word 3, 1, 4, 1, 5, 9, 0 dest: .word 0, 0, 0,

 ALSO PLEASE EXPLAIN THE FIXED ERRORS PLEASE! arrcpy.s for 1-3 .data

ALSO PLEASE EXPLAIN THE FIXED ERRORS PLEASE!

arrcpy.s for 1-3

.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

jal puti # print it

la $a0,countmsg # $a0

jal puts # print it

li $a0,0x0A # $a0

jal putc # print it

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

FOR THE LAST QUESTIONS ARRCOPY.S

.file 1 "arrcopy.c"

.globl source

.data

.align 2

source:

.word 3

.word 1

.word 4

.word 1

.word 5

.word 9

.word 0

.rdata

.align 2

$LC0:

.ascii "%d values copied \000"

.text

.align 2

.globl main

.ent main

main:

.frame $sp,24,$31 # vars= 0, regs= 1/0, args= 16, extra= 0

.mask 0x80000000,-8

.fmask 0x00000000,0

subu $sp,$sp,24

sw $31,16($sp)

jal __main

la $9,source

lw $2,0($9)

move $8,$0

beq $2,$0,$L8

move $7,$0

la $10,dest

$L6:

addu $8,$8,1

sll $3,$8,2

addu $5,$7,$9

addu $2,$3,$9

addu $6,$7,$10

lw $4,0($2)

move $7,$3

lw $3,0($5)

#nop

sw $3,0($6)

bne $4,$0,$L6

$L8:

la $4,$LC0

move $5,$8

jal printf

lw $31,16($sp)

move $2,$0

addu $sp,$sp,24

j $31

.end main

.comm dest,40

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 $vO. 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. (Exercise) Compiled C -> MIPS This exercise contains a function that does the same array copy functionality. However, now we wrote the code in C and used a cross compiler to automatically generate the MIPS code. You will find the original C code in arrcopy.c and auto-generated assembly in arrcopy.s Now look in arrcopy.s to answer the following Q4. Where is the source pointer stored originally? Q5. Where is the dest pointer stored originally? Q6. What instruction is used to load the address of source and dest pointers? Q7. Where does the loop to copy values start? (give line # and the first instruction and/or label of where it is) Q8. Explain what each line in the loop is trying to do in the following format: Instruction : add $4, $0, $0 (as an example) Purpose: to do nothing Corresponding C : x 0; 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 $vO. 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. (Exercise) Compiled C -> MIPS This exercise contains a function that does the same array copy functionality. However, now we wrote the code in C and used a cross compiler to automatically generate the MIPS code. You will find the original C code in arrcopy.c and auto-generated assembly in arrcopy.s Now look in arrcopy.s to answer the following Q4. Where is the source pointer stored originally? Q5. Where is the dest pointer stored originally? Q6. What instruction is used to load the address of source and dest pointers? Q7. Where does the loop to copy values start? (give line # and the first instruction and/or label of where it is) Q8. Explain what each line in the loop is trying to do in the following format: Instruction : add $4, $0, $0 (as an example) Purpose: to do nothing Corresponding C : x 0

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!