Write an assembly program to determine the number of decimal
Write an assembly program to determine the number of (decimal) 45’s found in memory from addresses $2000 through $207F. Counting the number of (decimal) 45 found in the memory should be done as a subroutine.
Solution
Code :
.data
msg .asciiz \"\ THE COUNT OF 45 within address 2000 - 207F is \"
.text
main:
li $s2,0
li $t0,0x2000
li $t1,0x207F
li $s0,0x2D
LOOP:
lw $t3,($t0)
bne $s0,$t3,next
addi $s0,$s0,1
next:
addi $t0,$t0,1
ble $t0,$t1,LOOP
li $v0,4
la $a0,msg
syscall
li $v0, 1
move $a0, $s0
syscall
li $v0,10
syscall
