MIPS 中的语法错误?
Syntax error in MIPS?
所以,我目前正在为我的大学学位学习 MIPS,我遇到了一个困扰我的语法错误,我似乎无法指出我哪里出错了,我的代码是用户输入两个数字的地方,控制台应该 return 一组数字,由于用户输入的两个数字,这些数字递增并完成打印,我目前在 PCSpim 上遇到语法错误,其中说 "spim: (parser) syntax error on line 55 of file" 第 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
看起来 addi 需要第三个值是立即值而不是寄存器...如果它是寄存器,它应该是 add
所以,我目前正在为我的大学学位学习 MIPS,我遇到了一个困扰我的语法错误,我似乎无法指出我哪里出错了,我的代码是用户输入两个数字的地方,控制台应该 return 一组数字,由于用户输入的两个数字,这些数字递增并完成打印,我目前在 PCSpim 上遇到语法错误,其中说 "spim: (parser) syntax error on line 55 of file" 第 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
看起来 addi 需要第三个值是立即值而不是寄存器...如果它是寄存器,它应该是 add