So I have a string in .data. The string is "e8 erercergrrrg,". I want to find the number of spaces in the string. It is stored in $a0, but in a different file and both the file I am writing the method for finding spaces and the file with the string is linked using the "include" feature.
My code isn't working even though I think the idea is right.
my code so far
lb $s1, ($a0)
la $s2 ' '
li $v0, 0
findNumSpaces:
beq $s1, $zero, printNumSpaces
beq $s1, $s2, isSpace
addi $a0, $a0, 1
lb $s1, ($a0)
j findNumSpaces
isSpace:
addi $v0, $v0, 1
addi $a0, $a0, 1
lb $s1, ($a0)
j findNumSpaces
printNumSpaces:
li $v0, 1
syscall
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.