1
本來我剛剛開始用匯編語言編程,本週我遇到了一些麻煩。我使用PCSpim在MIPS中編寫程序,程序提示用戶輸入兩個非負整數。不過,由於某些原因,我的代碼使兩個提示都出現在同一行上,只會接受一個整數。誰能幫我嗎?我不習慣語法,可以使用一些指針。用戶輸入問題
.text
.align 2
.globl main
# Prompts the user for two non-negative integers, x and y, and then finds the greatest common divisor of the two.
main:
la $a0, prompt
li $v0, 4
syscall # Display prompt for the x integer.
li $v0, 5
syscall # Get x integer response.
move $t0, $v0
la $a1, secondprompt
li $v1, 4
syscall # Display prompt for the y integer
li $v1, 5 # Get y integer response
syscall
move $t1, $v1
prompt: .asciiz "Enter a non-negative integer: \n"
secondprompt: .asciiz "Enter a second non-negative integer: \n"
我這樣做是因爲我認爲他們將不得不被存儲在不同的寄存器中,因爲它們可能是不同的值?他們應該仍然是t1和t0 – BleuCheese
$ t1對於第二個值是可以的 –
太棒了。非常感謝。 – BleuCheese