Как создать цикл while для этого кода сборки ARM? - PullRequest
0 голосов
/ 26 сентября 2019
.cpu cortex-a53
.fpu neon-fp-armv8

.data

string: .asciz "Enter a Fibonacci term: "
scan: .asciz "%d"
result: "The %dth Fibonacci number is: %d\n"

.text
.align 2
.global main
.type main, %function

main:

push {fp, lr} @pushes on to stack
add fp, sp, #4 @adds the bytes to the stack

ldr r0, =string @loads string prompt into r0
bl printf @prints the string
sub sp, sp, #4 @allocates memory for sp
ldr r0, =scan @loads scan into r0
mov r1, sp @sp is moved to r1
bl scanf @branches to scanf

ldr r5, [sp] @loads sp to r5
add sp, sp, #4 @creates bytes on stack

whileloop:

cmp r0, #0 @compares user input to 0
bgt myexit @closes program if input is 0
mov r2, #0 @stores first term of fib
mov r3, #1 @stores second term of fib
add r2, r2, r3 @adds r2 & r3 then overwrites r2
...