Advertisement
Guest User

Untitled

a guest
Apr 9th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. .cpu cortex-a72
  2. .fpu neon-fp-armv8
  3.  
  4. .data
  5. input: .asciz "Please enter the Fibonacci number: "
  6. recur: .asciz "%d"
  7. output: .asciz "%d is the number in the sequence."
  8.  
  9. .text
  10. .align 2
  11. .global main
  12. .type main, %function
  13.  
  14. main:
  15.  
  16. push {fp, lr}
  17. add fp, sp, #4
  18.  
  19. mov r5, #1 @ these registers and r1 will be used to
  20. mov r6, #0 @ calculate the fibonacci sum
  21.  
  22. ldr r0, =input @read Fibonacci no.
  23. bl printf
  24. ldr r0, =recur
  25. sub sp, sp, #4
  26. mov r1, sp
  27. bl scanf
  28. ldr r7, [sp]
  29.  
  30. loop:
  31. add r0, r5, r6
  32. mov r6, r5
  33. mov r5, r0
  34. sub r7, r0, #1
  35. cmp r7, #1
  36. ble end
  37. b loop
  38.  
  39. end:
  40. ldr r0, =output
  41. mov r1, r7
  42. bl printf
  43. sub sp, fp, #4
  44. pop {fp, pc}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement