Arm assembly fibonacci
/*
* fibonacci.s
* Computes the nth fibonacci number.
*
*/
.syntax unified
.global _start
_start:
mov r0, 0 @ answer
mov r1, 9 @ n = 9
mov r2, 0 @ first value in sequence
mov r3, 1 @ second value in sequence
mov r4, 0 @ i = 0
loop:
add r4, r4, 1
cmp r1, r4
ble _exit
mov r5, r0
add r0, r2, r3
mov r2, r0
mov r3, r5
bal loop
_exit:
mov r7, 1
swi 0