Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- ArrayOfByte: .byte 127, 0, 127, 0, 127, 0, 127
- ArrayOfWord: .word 5, 6 -12, 4
- sizeB: .word 7
- sizeW: .word 4
- sumB: .word 0
- sumW: .word 0
- nl: .asciiz "\n"
- .text
- main:
- lw $t1, sizeB
- lw $t2, sizeW
- la $a1, ArrayOfByte
- li $t0, 0 #counter
- li $t3, 0 # sum
- loop_1:
- lb $s0, 0($a1)
- beq $t0, $t1, next_1
- add $a1, $a1, 1
- add $t3, $t3, $s0
- add $t0, $t0, 1
- j loop_1
- next_1:
- sw $t3, sumB
- li $v0, 1
- lw $a0, sumB
- syscall
- li $t3, 0 # sum
- li $t0, 0 #counter
- la $a1, ArrayOfWord
- loop_2:
- lw $s0, 0($a1)
- beq $t0, $t2, next_2
- add $a1, $a1, 4
- add $t3, $t3, $s0
- add $t0, $t0, 1
- j loop_2
- next_2:
- sw $t3, sumW
- li $v0, 4
- la $a0, nl
- syscall
- li $v0, 1
- lw $a0, sumW
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement