Bugs in program


Question:

Bugs in program

The following program tries to copy words from the address in register $a0 to the address in register $a1, counting the number of words copied in register $v0. The program stops copying when it finds a word equal to 0. You do not have to preserve the contents of registers $v1, $a0, and $a1. This terminating word should be copied but not counted.

addi $v0, $zero, 0 #Initialize count
loop: lw $v1, 0($a0) # Read next word from source
sw $v1, 0($a1) # write to destination

addi $a0, $a0, 4 # Advance pointer to next source
addi $a1, $a1, 4 # Advance pointer to next destination
beq $v1, $zero, loop #loop if word copied != zero

There are multiple bugs in this MIPS program; fix them and turn in a bug - free version.

and one more problem:
show the singele MIPS instruction or minimal sequence of instructions for this C statement:

b = 25 | a;
Anssume that a corresponds to register $t0 and b corresponds to register $t1.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Bugs in program
Reference No:- TGS01937483

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)