1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # !> Print an array of numbers in a "for loop"
.global main
.text
main:
enter $0, $0
mov $numbers, %r12
mov $0, %r13 # i = 0
loop:
cmpq $8, %r13 # i < 8
jge loop_end # -> end the loop
# numbers -> %r12
# i -> %r13
mov $format, %rdi
mov (%r12, %r13, 8), %rsi
mov $0, %al
call printf
incq %r13
jmp loop
loop_end:
mov $0, %rax
leave
ret
.data
numbers:
.quad 1, 2, 3, 4, 5, 6, 7, 8
format:
.asciz "%ld\n"
|