Advertisement
sailorbob74133

CompOrg Exam 2009B A1 Q 3.1

Jan 23rd, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Assume A and B are int arrays
  2. addi $t0, $a1, 400  # $t0 = one element past end of array A
  3. loop:
  4. addi $a1, $a1, 1 # A++
  5. addi $a2, $a2, 1 # B++
  6. lw $t1, 0($a2) # $t1 = B[i]
  7. bltz $t1, loop  # goto loop if B[i] is less than 0
  8. lw $t2, -4($a1) # $t2 = A[i-1]
  9. add $t3, $t1, $t2
  10. sw $t3, 0($a1)
  11. bne $a1, $t0, loop # while $a1 != $t0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement