Computer Science Homework Solutions
Problem
#67277

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.


Thank you for help

Solution
What is this?
By OTA - Overall OTA Rating
Xiao Liu, MS - 4.7/5
Purchase Cost Now
$2.19 CAD (was ~$35.91)
Included in Download
  • Plain text response
  • Attached file(s):
    • MIPS_asm.doc
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
Browse