我正在尝试将用户输入的数字与100进行比较,如果该数字大于或等于100,则打印“该数字大于或等于”,如果小于100,则进行相应打印。它可以很好地处理输入部分,但是在接受输入后程序立即结束。我对组装非常陌生,这是我第二天开始工作,所以请放轻松。感谢您的帮助!
.global main
main:
prompt:
ldr r0, = numPrompt
bl printf
get_input:
ldr r0, =numInputPattern
sub sp, sp, #4
mov r1, sp
bl scanf
ldr r1, [sp, #0]
add sp, sp, #4
printinputasNum:
cmp r0, #100 @compare num in r0 to 100
bne Test1 @if not equal, jump to Test1
ldr r0, = greaterorequalOutput
bl printf
b ExitAll
Test1: blt Test2
ldr r0, = lessthanOutput
bl printf
b ExitAll
Test2: ldr r0, = greaterorequalOutput
ExitAll:
myexit:
mov r7, #0x01
svc 0
.data
.balign 4
numPrompt: .asciz "Input a number: "
.balign 4
numInputPattern: .asciz "%d"
.balign 4
lessthanOutput: .asciz "The input number is less than 100 \n"
.balign 4
greaterorequalOutput: .asciz "The input number is greater than or equal to 100 \n"
.global printf
.global scanf