我的代码有问题。我正在创建一个程序,它将读取一个字符串,将其保存到一个数组中,然后输出每个字母在字符串中使用的次数。目前,我只是将字符串输出到屏幕时遇到问题。输出字符串但循环永远不会退出, $t2 值可能永远不会设置为值?
.data
intro: .asciiz "Andrew Lofgren, Letter Checker Program"
question: .asciiz "\nPlease enter a string for evaluation: "
alphabet: .ascii "ABCDEFGHIJKLMONOPQRSTUVWXYZ"
results: .space 104
string: .space 1024
.text
main:
jal setup
jal analyze
#jal results
li $v0, 10
syscall
setup:
li $v0, 4 # outputing name and program information
la $a0, intro
syscall
li $v0, 4 # asksing for string input
la $a0, question
syscall
li $v0, 8
la $a0, string
li $a1, 1024
syscall
jr $ra # return
analyze:
la $t0, string # taking string and saving into a tmp
move $t2, $t0 # backup of orignal address
find:
beq $t1, 0, print
addi $t0, $t0, 1
j find
print:
blt $t0, $t2, end #PROBLEM HERE
li $v0, 11
lb $a0, 0($t0)
syscall
addi $t0, $t0, 1
j print
end:
jr $ra