所以,我目前正在为我的大学学位学习 MIPS,我遇到了一个困扰我的语法错误,我似乎无法指出我哪里出错了,我的一段代码是一个用户输入两个数字,控制台应该返回一组数字,由于用户输入的两个数字而增加并完成打印,我目前在 PCSpim 上遇到语法错误,上面写着“spim:(解析器)语法文件第 55 行出现错误”第 55 行是addi $t0, $t0, $t2
我要发送的代码,如果有人能指出我在哪里解决这个问题的大致方向,那就太好了。
.data
text: .asciiz "Enter any number: "
message: .asciiz " After while loop is done "
str: .asciiz "Enter a number to add: "
newline: .asciiz "\n"
space: .asciiz ","
.text
main:
# Printing out the text
li $v0, 4
la $a0, text
syscall
# Getting user input
li $v0, 5
syscall
# Moving the integer input to another register
move $t1, $v0
# Printing out the newline
li $v0, 4
la $a0, newline
syscall
# Printing out the text
li $v0, 4
la $a0, str
syscall
# Getting user input
li $v0, 5
syscall
# Moving the integer input to another register
move $t2, $v0
# Printing out the newline
li $v0, 4
la $a0, newline
syscall
# i = 0
addi $t0, $zero, 0
while:
bgt $t0, $t1, exit
jal printNumber
addi $t0, $t0, $t2
j while
exit:
li $v0, 4
la $a0, message
syscall
#End of program
li $v0, 10
syscall
printNumber:
la $v0, 1
add $a0, $t0, $zero
syscall
li $v0, 4
la $a0, space
syscall
jr $ra