내 CS 클래스에 대한 MIPS 어셈블리 언어를 배우려고합니다. 나는 문법적으로이 프로그램을 쓰려고 애 쓰고있다. 교수님이 우리에게 준 다른 예를 보았습니다. 나는 그것을 철저히 따랐습니다. 내 지점에서 동일한 조건이 아니라는 오류가 나타납니다. 코드는 다음과 같습니다.MIPS bne 구문 분석기 오류
# 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
^
모든 도움이 크게 감사하겠습니다! 정말 고맙습니다! 첫 번째 인수는, 귀하의 경우, 당신은 $a0
가 $0
같지 않으면 분기 그것을 말하고있다 두 번째 인수와 동일하지 않은 경우
방금 테스트했습니다. 이, 나는 여전히 이전과 같은 오류가 발생합니다. –