Ich versuche, die MIPS-Assemblersprache für meine CS-Klasse zu lernen. Ich kämpfe syntaktisch mit dem Versuch, dieses Programm zu schreiben. Ich habe mir das andere Beispiel angesehen, das mein Professor uns gegeben hat, und ich habe es genau verfolgt. Ich erhalte einen Fehler bei meinem Zweig, der nicht gleich ist. Der Code ist wie folgt.MIPS bne Parser Syntaxfehler
# 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
Ich weiß, dass dieser Code jetzt nicht richtig funktioniert. Ich bitte jedoch nicht um Hilfe bei der Programmierung dieser Funktion, ich möchte sie einfach ausführen können, damit ich sehen kann, was vor sich geht. Bevor ich die Datei sogar laden kann, erhalte ich einen Syntaxfehler in der folgenden Zeile.
bne $a0,$0,1 # Branch if the argument is not equal to zero
Der Fehler lautet wie folgt.
spim: (parser) syntax error on line 35 of file ...
bne $a0,$0,1 #Branch if the argument is not equal to zero
^
Jede und alle Hilfe würde sehr geschätzt werden mit diesem! Ich danke dir sehr!
sein, die ich gerade getestet habe Ich bekomme immer noch denselben Fehler wie zuvor. –