.ifndef _io_s_file _io_s_file: # | int | -> cont .thunkcode print_bin needs_alloc $040 thunkto %rsi, $print_bin_fini, $2, %rbp, %rsi enter 020(%rbp) # arg -> | ret | cont | .thunkcode print_bin_fini needs_alloc $0110 #64 bit characters + 8 backup mov 010(%rsi), %rax # make a string mov %rsp, %r15 sub $1, %r15 movb $0x0a, (%r15) # newline at the end _print_bin_fini_loop: mov %al, %bl and $1, %bl add $0x30, %bl sub $1, %r15 movb %bl, (%r15) shr $1, %rax jnz _print_fini_loop mov $1, %rdi #stdout mov %rsp, %rdx sub %r15, %rdx #size mov %r15, %rsi #buf mov $1, %rax #write syscall mov 020(%rbp), %rsi # this is the original thunk which just got evaluated movq $0, 010(%rsi) # it got evaluated to int 0 movq $INT_code, 0(%rsi) enter 030(%rbp) # the original continuation # | int | -> cont .thunkcode print # this is the same as above but decimal needs_alloc $040 thunkto %rsi, $print_fini, $2, %rbp, %rsi enter 020(%rbp) # arg -> | ret | cont | .thunkcode print_fini needs_alloc $0110 mov 010(%rsi), %rax mov %rsp, %r15 sub $1, %r15 movb $0x0a, (%r15) mov $10, %rbx _print_fini_loop: mov $0, %rdx div %rbx add $0x30, %dl sub $1, %r15 movb %dl, (%r15) test %rax, %rax jnz _print_fini_loop mov $1, %rdi mov %rsp, %rdx sub %r15, %rdx mov %r15, %rsi mov $1, %rax syscall mov 020(%rbp), %rsi movq $0, 010(%rsi) movq $INT_code, 0(%rsi) enter 030(%rbp) .endif # _io_s_file