我想了解我的CS类的MIPS汇编语言。我正努力在语法上试图编写这个程序。我看了我的教授给我们的另一个例子,我紧紧跟随它。我在我的分支上遇到了一个不对等的错误。代码如下。MIPS的解析器语法错误
# Main program that will call subroutine fib to calculate the fibonacci and
# print the result
.text
.globl main
sub $sp,$sp,4
sw $ra,0($sp)
li $a0,3
jal fib
la $a0,str
syscall
sw $a0,0($v0)
syscall
lw $ra,0($sp)
add $sp,$sp,4
jr $ra
.data
str:
.asciiz "fib = "
.text
fib:
sw $a1,0($a0)
bne $a0,$0,1 # Branch if the argument is not equal to zero
add $v0,$0 # If it is equal to 0,add 0 to the return value.
addi $t0,$0,1 # Create temporary equal to 1.
bne $a0,$t0,1 # Branch if argument is not equal to 1.
addi $v0,1 # If it is,add one to the return value.
addi $sp,$sp,-4 # Create space on the stack for the return value.
sw $ra,0($sp) # Save old return address to the stack
addi $a0,-1
jal fib #jump to fib and save address
addi $a0,$a1,-2 #subtract 2 from the starting number.
jal fib
lw $ra,0($sp)
add $sp,$sp,4
jr $ra
我知道这段代码现在不能正常工作。但是,我不是要求编程这个功能的帮助,我只是希望能够运行它,以便我可以看到发生了什么。在我甚至可以加载文件之前,我在下面一行中收到语法错误。
bne $a0,$0,1 # Branch if the argument is not equal to zero
错误内容如下。
spim: (parser) syntax error on line 35 of file ...
bne $a0,$0,1 #Branch if the argument is not equal to zero
^
任何和所有的帮助将不胜感激!非常感谢!
我刚刚测试过这个,我仍然得到和以前一样的错误。 –