Skip to content

Instantly share code, notes, and snippets.

@Megawats777
Created March 6, 2020 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Megawats777/1344664ce18a295652ffbd1871482832 to your computer and use it in GitHub Desktop.
Save Megawats777/1344664ce18a295652ffbd1871482832 to your computer and use it in GitHub Desktop.
.text
.globl _start
min = 0
max = 30
_start:
mov x19, min
mov x20, 10
loop:
udiv x22, x19, x20
msub x23, x20, x22, x19
add w22, w22, 48
add w23, w23, 48
mov x0, 1 /* file descriptor: 1 is stdout */
adr x1, msg /* message location (memory address) */
mov x2, len /* message length (bytes) */
cmp w22, 48
b.eq printFirst
adr x21, msg+6
strb w22,[x21]
printFirst:
adr x21, msg+7
strb w23,[x21]
mov x8, 64 /* write is syscall #64 */
svc 0 /* invoke syscall */
add x19, x19, 1
cmp x19, max
b.ne loop
mov x0, 0 /* status -> 0 */
mov x8, 93 /* exit is syscall #93 */
svc 0 /* invoke syscall */
.data
msg: .ascii "Loop: \n"
len= . - msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment