0
ARMアセンブリでscanfを使用して複数の値(1度に1つずつ)を読み込もうとしています。私はscanf部分を動作させることができますし、明らかに値を正しく保存しています。しかし、私はそれらを取得したいときは、私は最後の番号を取得し、他のものは他のものを取得します。ARMアセンブリ:scanfによって格納された値は正しく保存されません。
これは、それが私に与えているものです。
Enter a number: 1
Enter a number: 2
You entered: 2129322344 and 2.
それはYou entered 1 and 2.
私のコードは次のようになりますと言う必要があります。
.global main
.func main
main:
PUSH {LR}
LDR R0, =entryMessage
BL printf
SUB SP, SP, #8
LDR R0, =scanformat
MOV R1, SP
BL scanf @ Number is saved in SP - 8
LDR R0, =entryMessage
BL printf
ADD SP, SP, #4
LDR R0, =scanformat
MOV R1, SP
BL scanf @ Number is saved in SP - 4
ADD SP, SP, #4 @ Restore SP to original
SUB SP, SP, #8 @ Prepare to read SP - 8 for first number
LDR R1, [SP] @ Read first number
ADD SP, SP, #4 @ Prepare to read SP - 4 for second number
LDR R2, [SP] @ Read second number
ADD SP, SP, #4 @ Restore SP to original
LDR R0, =printMessage
BL printf
POP {PC}
_exit:
BX LR
.data
entryMessage: .asciz "Enter a number: "
scanformat: .asciz "%d"
printMessage: .asciz "You entered: %d and %d.\n"
それが唯一のことですなぜ誰かが教えてもらえます最後の値は正しく読み込まれますか?