Advertisement
Guest User

ass6

a guest
Jun 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.  
  3. ArrayOfByte: .byte 127, 0, 127, 0, 127, 0, 127
  4. ArrayOfWord: .word 5, 6 -12, 4
  5. sizeB: .word 7
  6. sizeW: .word 4
  7. sumB: .word 0
  8. sumW: .word 0
  9. nl: .asciiz "\n"
  10. .text
  11. main:
  12. lw $t1, sizeB
  13. lw $t2, sizeW
  14. la $a1, ArrayOfByte
  15. li $t0, 0 #counter
  16. li $t3, 0 # sum
  17.  
  18. loop_1:
  19. lb $s0, 0($a1)
  20. beq $t0, $t1, next_1
  21. add $a1, $a1, 1
  22. add $t3, $t3, $s0
  23. add $t0, $t0, 1
  24. j loop_1
  25.  
  26. next_1:
  27. sw $t3, sumB
  28.  
  29. li $v0, 1
  30. lw $a0, sumB
  31. syscall
  32.  
  33. li $t3, 0 # sum
  34. li $t0, 0 #counter
  35. la $a1, ArrayOfWord
  36.  
  37. loop_2:
  38. lw $s0, 0($a1)
  39. beq $t0, $t2, next_2
  40. add $a1, $a1, 4
  41. add $t3, $t3, $s0
  42. add $t0, $t0, 1
  43. j loop_2
  44.  
  45. next_2:
  46. sw $t3, sumW
  47.  
  48. li $v0, 4
  49. la $a0, nl
  50. syscall
  51.  
  52. li $v0, 1
  53. lw $a0, sumW
  54. syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement