diff options
Diffstat (limited to 'include/io.s')
| -rw-r--r-- | include/io.s | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/io.s b/include/io.s new file mode 100644 index 0000000..c348e7f --- /dev/null +++ b/include/io.s @@ -0,0 +1,44 @@ + +.ifndef _io_s_file +_io_s_file: + +# | int | -> cont +.thunkcode print + push %rsi + push %rbp + pushq $2 + pushq $print_fini + + mov %rsp, %rsi + enter 020(%rbp) + +# arg -> | ret | cont | +.thunkcode print_fini + mov 010(%rsi), %rax + + # make a string + mov %rsp, %r15 + sub $1, %r15 + movb $0x0a, (%r15) + print_fini_next: + mov %al, %bl + and $1, %bl + add $0x30, %bl + sub $1, %r15 + movb %bl, (%r15) + shr $1, %rax + jnz print_fini_next + + mov $0, %rdi #stdin + mov %rsp, %rdx + sub %r15, %rdx #size + mov %r15, %rsi #buf + mov $1, %rax #write + syscall + + mov 020(%rbp), %rsi + movq $0, 010(%rsi) + movq $INT_code, 0(%rsi) + enter 030(%rbp) + +.endif # _io_s_file |
