0
我對MIPS相對較新,並且使用SPIM作爲我的編譯器。我試圖寫該程序使用十進制整數的用戶的輸入,並確定的有多少個零,一個是它的二進制表示:使用MIPS打印結果時出現語法錯誤
.data
ques: .asciiz "Enter a decimal integer:\n"
zer: .asciiz "Number of 0's\n"
one: .asciiz "Number of 1's\n"
buf: .word 16
ans: .word 40
.text
.globl main
#Prompt user for number
main:
la $a0, ques #asks user to enter decimal integer
li $v0, 4
syscall
#Read the input
li $v0, 5 #reads user input
syscall
move $s3, $v0 #stores user input in register
jr count #jumps to count function
count:
addi $s7, $s7, 1 #increments with each run of the loop
beq $s7, 32, end #checks if all parts of the binary integer have been checked
andi $s0, $s3, 1 #ands one to binary number
beq $s0, 0, zeros #goes to incrementing function for 0
beq $s0, 1, ones #goes to incrementing function for 1
zeros:
addi $s5, $s5, 1 #increments 0 counter by one
srlv $s3, $s3, 1 #shifts binary digit right by one
j count #returns to count function
ones:
addi $s6, $s6, 1 #increments 1 counter by one
srlv $s3, $s3, 1 #shifts binary digits right by one
j count #returns to count function
end:
la $a0, zer #Prints zeros header
li $v0, 4
syscall
la $a3, $s5 #prints number of zero's
li $v0, 1
syscall
la $a0, one #prints ones header
li $v0, 4
syscall
la $a3, $s6
li $v0, 1
syscall
jr $31 #end program
我的問題是,當我嘗試打印的結果我程序,我得到一個語法錯誤:
spim: (parser) syntax error on line 43 of file test.mal
la $a3, $s5 #prints number of zero's
^
我已經嘗試了很多事情來解決這個問題,但我真的不甚至不確定是什麼問題。任何的意見都將會有幫助。