2011-10-10 57 views
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" 

回答

3

你在哪里读过你应该使用$ a1和$ v1?这两个数字应该是$ a0和$ v0。

+0

我这样做是因为我认为他们将不得不被存储在不同的寄存器中,因为它们可能是不同的值?他们应该仍然是t1和t0 – BleuCheese

+0

$ t1对于第二个值是可以的 –

+0

太棒了。非常感谢。 – BleuCheese