diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-06 00:25:53 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-06 00:25:53 +0200 |
| commit | 74cad993376dc269e8389fbf150be9ecc36890c7 (patch) | |
| tree | 32a2dbb382836ee0f1853fe5e63036d044fea77d /include/io.s | |
| parent | 46d84e91ebe48ade19bd3f5e18360bf853b53968 (diff) | |
| download | uskel-74cad993376dc269e8389fbf150be9ecc36890c7.tar.gz uskel-74cad993376dc269e8389fbf150be9ecc36890c7.tar.bz2 | |
fibs work
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 |
