.global main main: mov $s_format, %rdi push %rax mov %rsp, %rsi xor %rax, %rax call scanf pop %r10 # maximum, where we stop in the sequence mov $1, %r8 # Trail, oldest mov $1, %r9 # Trail, newest mov $1, %r11 # Number we're on looptop: add %r9, %r8 # Print and swap routine mov $p_format, %rdi mov %r8, %rdx mov %r11, %rsi xor %rax, %rax push %r8 push %r9 push %r10 push %r11 call printf pop %r11 pop %r10 pop %r8 pop %r9 inc %r11 cmp %r11, %r10 jg looptop ret p_format: .asciz "%lu: %lu\n" s_format: .asciz "%d"