Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. @ define system
  2. .cpu cortex-a53
  3. .fpu neon-fp-armv8
  4. .syntax unified @ modern syntax
  5.  
  6. @ constant data
  7. .section .rodata
  8. .align 2
  9.  
  10. resultMsg:
  11. .asciz "The sum is %i\n"
  12.  
  13. @ program
  14. .text
  15. .align 2
  16. .global main
  17. .type main, %function
  18.  
  19. main:
  20. @ stack:
  21. @ 0: lr
  22. @ -4: a = 1 <-- sp + 32
  23. @ -8: b = 2 <-- sp + 28
  24. @ -12: c = 3 <-- sp + 24
  25. @ -16: d = 4 <-- sp + 20
  26. @ -20: e = 5 <-- sp + 16
  27. @ -24: f = 6 <-- sp + 12
  28. @ -28: g = 7 <-- sp + 8
  29. @ -32: h = 8 <-- sp + 4
  30. @ -36: i = 9 <-- sp
  31.  
  32. push { lr }
  33.  
  34. @ a = 1
  35. mov r0, 1
  36. push { r0 }
  37. @ b = 2
  38. mov r0, 2
  39. push { r0 }
  40. @ c = 3
  41. mov r0, 3
  42. push { r0 }
  43. @ d = 4
  44. mov r0, 4
  45. push { r0 }
  46. @ e = 5
  47. mov r0, 5
  48. push { r0 }
  49. @ f = 6
  50. mov r0, 6
  51. push { r0 }
  52. @ g = 7
  53. mov r0, 7
  54. push { r0 }
  55. @ h = 8
  56. mov r0, 8
  57. push { r0 }
  58. @ i = 9
  59. mov r0, 9
  60. push { r0 }
  61.  
  62. bl sumNine
  63. mov r1, r0
  64.  
  65. @ print total
  66. ldr r0, resultMsgAddr
  67. @ total already in r1
  68. bl printf
  69.  
  70. mov r0, 0 @ return 0;
  71. add sp, sp, 36
  72. pop { pc }
  73.  
  74. .align 2
  75. resultMsgAddr:
  76. .word resultMsg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement