mips - Count number of lowercase letters -
so have created programme count number of lowercase letters in string. problem having when reach end of string , nl
character reached, line beq $t0, $t1, end
not beingness executed; continues indefinitely. i'm not sure i'm doing incorrectly.
.data msg1: .word 0:24 .text .globl main main: addu $s0, $0, $ra li $v0, 8 la $a0, msg1 la $a1, 100 syscall loop: lb $t0, 4($a0) li $t1, 0x0a beq $t0, $t1, end continue: li $t1, 'a' blt $t0, $t1, count li $t1, 'z' bgt $t0, $t1, count count: addi $t4, $t4, 1 j loop end: li $v0, 1 addu $a0, $t2, $0 syscall jr $ra
you compare 4($a0)
0x0a
on each iteration of loop, never alter $a0
in loop, not advancing through string , never @ \n
@ end of string.
there few other bugs in code.
use @ start of loop:
loop: lb $t0, 0($a0) addiu $a0, $a0, 1 ...
mips
No comments:
Post a Comment