Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .globl _start
- start = 0
- end = 31
- _start:
- mov x4, start /* Init iterator to 0 */
- loop:
- mov x11, 10 /* Store the value 10 in register to parse 2 digit numbers */
- udiv x9, x4, x11 /* divide x4 by x11, put quotient into x9 */
- msub x10, x11, x9, x4/* load x10 with x4-(x11*x9), the remainder of iter % 10 */
- add x12, x9, 0x30 /* convert iter (10s place) to ascii and store in register */
- add x13, x10, 0x30 /* convert iter (1s place) to ascii and store in register */
- cmp x9, 0 /* Check to see if 10s place is 0 */
- adr x1, msg /* store message location (memory address) in register */
- b.eq print /* if it is equal, skip adding 10s digit */
- str x12, [x1, 7] /* Store the iterator (10s place) ascii into the ...*/
- /* ... address of string + 7 bytes*/
- print:
- mov x0, 1 /* file descriptor: 1 is stdout */
- str x13, [x1, 8] /* Store the iterator (1s place) ascii into the ...*/
- /* ... address of string + 8 bytes*/
- mov x2, len /* message length (bytes) */
- mov x8, 64 /* write is syscall #64 */
- svc 0 /* invoke syscall */
- add x4, x4, 1 /* increment the iterator */
- cmp x4, end /* check to see if the iterator equals to end */
- b.ne loop /* if iterator not equal to end, go back to loop label */
- mov x0, 0 /* status -> 0 */
- mov x8, 93 /* exit is syscall #93 */
- svc 0 /* invoke syscall */
- .data
- msg: .ascii "\nLoop: "
- len= . - msg
Add Comment
Please, Sign In to add comment