1

文字通り、今週アセンブリ言語でプログラミングを始めたばかりで、問題が発生しています。PCSpim を使用して MIPS でプログラムを作成していますが、プログラムはユーザーに 2 つの負でない整数を入力するように求めます。ただし、何らかの理由で、私のコードでは両方のプロンプトが同じ行に表示され、1 つの整数しか受け入れられません。誰でも私を助けることができますか?私は構文にまったく慣れていないので、いくつかのポインターを使用できます。

.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"
4

1 に答える 1

3

$a1 と $v1 を使用する必要があることをどこで読みましたか? どちらの番号も $a0 と $v0 である必要があります。

于 2011-10-10T01:36:34.507 に答える