MIPS无限循环/加载字符字节错误

问题描述:

我试图让用户输入'Y'重新启动程序(分支回主)或'N'(分支结束程序)。我正在使用系统调用操作码12读取单个字符MIPS无限循环/加载字符字节错误

endCheck: 
la $a0, newLine    # Print the newLine 
li $v0, 4 
syscall 

la $a0, endPrompt   # print the Start over message 
li $v0, 4 
syscall 

li $v0, 12    # take in char input 
syscall 
move $t0, $v0 

lb $t1, ($t0)    # Load the char byte into t1 

beq $t1, 89, main   # Go back to start if they entered 'Y' 
bne $t1, 78, endCheck   # Ask the user again because input was not 'N' or 'Y' 

li $v0, 10    
syscall 

我在lb行上得到一个错误。即使我在数据段上分配了1个字节的空间,并将输入读为1个字符的字符串,我也会遇到一个无限循环(当它正确编译时它总是回到endCheck)我做错了什么?

当您使用syscall 12时,字符本身返回$v0。它不会给你一个读取角色的地址。完全可以省略lb

因此,当您应该使用$t0时,您正在使用$t1进行比较。