diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-15 11:07:35 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-15 11:07:35 +0200 |
| commit | 2861823b2faa27dd1cdf2ab992513e5a2fd9d2ad (patch) | |
| tree | d899194a9cc8cfddfbb6419cb3b9343b1896742c /include | |
| parent | d31d550a852fb52195dbaebbd699cc2e6d696a8b (diff) | |
| download | uskel-2861823b2faa27dd1cdf2ab992513e5a2fd9d2ad.tar.gz uskel-2861823b2faa27dd1cdf2ab992513e5a2fd9d2ad.tar.bz2 | |
add primop1
Diffstat (limited to 'include')
| -rw-r--r-- | include/primops.s | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/primops.s b/include/primops.s index 3fb03b8..ec3c79c 100644 --- a/include/primops.s +++ b/include/primops.s @@ -4,6 +4,38 @@ _primops_s_file: .include "include/data.s" +# TODO: try to generalize the returning macros + +.macro .primop1 name +# | arg1 | -> cont +.thunkcode \name + # push a thunk for collecting the first arg and set it as continuation + thunkto %rsi, $\name\()_fini, $2, %rbp, %rsi + enter 0x10(%rbp) # evaluate arg1 + +# arg1 -> | ret | cont | +.thunkcode \name\()_fini + # at this point arg1 is pointed to by %rsi +.endm + +.macro primop1_ret_int val + # the result should now be in %rax + mov 020(%rbp), %rsi # save result to the original primop2 thunk (we don't need IND) + movq \val, 010(%rsi) + movq $INT_code, 0(%rsi) + + enter 030(%rbp) # eval cont, returning %rsi +.endm + +.macro primop1_cont_indirect new + mov 020(%rbp), %rdi # load the original thunk + mov 030(%rbp), %rsi # set the continuation + movq \new, 010(%rdi) # set the indirect to the new thunk + movq $IND_code, 0(%rdi) + enter \new # continue evaluating the new thunk +.endm + + .macro .primop2 name # | arg1 | arg2 | -> cont .thunkcode \name |
