Guest User

Untitled

a guest
Sep 30th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. .text
  2. .globl _start
  3.  
  4. start = 0
  5. end = 31
  6.  
  7. _start:
  8. mov x4, start /* Init iterator to 0 */
  9. loop:
  10. mov x11, 10 /* Store the value 10 in register to parse 2 digit numbers */
  11. udiv x9, x4, x11 /* divide x4 by x11, put quotient into x9 */
  12. msub x10, x11, x9, x4/* load x10 with x4-(x11*x9), the remainder of iter % 10 */
  13.  
  14. add x12, x9, 0x30 /* convert iter (10s place) to ascii and store in register */
  15. add x13, x10, 0x30 /* convert iter (1s place) to ascii and store in register */
  16.  
  17. cmp x9, 0 /* Check to see if 10s place is 0 */
  18. adr x1, msg /* store message location (memory address) in register */
  19. b.eq print /* if it is equal, skip adding 10s digit */
  20. str x12, [x1, 7] /* Store the iterator (10s place) ascii into the ...*/
  21. /* ... address of string + 7 bytes*/
  22.  
  23. print:
  24. mov x0, 1 /* file descriptor: 1 is stdout */
  25. str x13, [x1, 8] /* Store the iterator (1s place) ascii into the ...*/
  26. /* ... address of string + 8 bytes*/
  27. mov x2, len /* message length (bytes) */
  28.  
  29. mov x8, 64 /* write is syscall #64 */
  30. svc 0 /* invoke syscall */
  31.  
  32. add x4, x4, 1 /* increment the iterator */
  33. cmp x4, end /* check to see if the iterator equals to end */
  34. b.ne loop /* if iterator not equal to end, go back to loop label */
  35.  
  36. mov x0, 0 /* status -> 0 */
  37. mov x8, 93 /* exit is syscall #93 */
  38. svc 0 /* invoke syscall */
  39.  
  40. .data
  41. msg: .ascii "\nLoop: "
  42. len= . - msg
Add Comment
Please, Sign In to add comment