Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .globl _start
- start = 0
- max = 100
- _start:
- /*setup initial loop counter */
- mov x19, start
- loop:
- /* Start loop here */
- /* Print the Loop string */
- mov x0, 1 /* file descriptor: 1 is stdout */
- adr x1, loop_msg /* message location (memory address) */
- mov x2, loop_msg_len /* message length (bytes) */
- mov x8, 64 /* write is syscall #64 */
- svc 0 /* invoke syscall */
- /* Print Numbers */
- mov x20, num_msg_len
- udiv x21, x19, x20
- cmp x19, x20
- mov x0, 1 /* file descriptor: 1 is stdout */
- adr x1, num_msg /* message location (memory address) */
- add x1, x1, x21 /* add the loop count */
- mov x2, 1 /* message length (bytes) */
- mov x8, 64 /* write is syscall #64 */
- svc 0 /* invoke syscall */
- msub x21, x20, x21, x19
- mov x0, 1 /* file descriptor: 1 is stdout */
- adr x1, num_msg /* message location (memory address) */
- add x1, x1, x21 /* add the loop count */
- mov x2, 1 /* message length (bytes) */
- mov x8, 64 /* write is syscall #64 */
- svc 0 /* invoke syscall */
- /* Print newline */
- mov x0, 1 /* file descriptor: 1 is stdout */
- adr x1, nl_msg /* message location (memory address) */
- mov x2, nl_msg_len /* message length (bytes) */
- mov x8, 64 /* write is syscall #64 */
- svc 0 /* invoke syscall */
- /* Increment loop */
- add x19, x19, 1
- /* compare the loop counter (x19) to the max value */
- cmp x19, max
- /* branch if less then the max */
- b.lt loop
- mov x0, 0 /* status -> 0 */
- mov x8, 93 /* exit is syscall #93 */
- svc 0 /* invoke syscall */
- .data
- loop_msg: .ascii "Loop: "
- loop_msg_len = . - loop_msg
- num_msg: .ascii "0123456789"
- num_msg_len = . - num_msg
- nl_msg: .ascii "\n"
- nl_msg_len = . - nl_msg
Add Comment
Please, Sign In to add comment