开发者

User input problems

I've literally just started programming in assembly language this week and I'm having some trouble. I'm making a program in MIPS using PCSpim and the program prompts the user to enter two non-negative integers. For some reason though, my code makes both prompts appear on the same line and will only accept one integer. Can anyone help me out? I'm not used to the syntax at all and could use a few pointers.

.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开发者_如何学Python 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"


Where have you read that you should use $a1 and $v1? It should be $a0 and $v0 for both numbers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜