diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-11-01 18:25:26 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-11-01 18:25:26 +0100 |
| commit | 1909e97d4615045e707710a2aaeae8bf702a8355 (patch) | |
| tree | acba7fd278ef27dbdb749f936b38a812a056176a /sum.s | |
| parent | 32d71ef9f25b4cebb2ae95b4f528bbc02f62ea31 (diff) | |
| parent | 970ffb4684dbd88bd54e909820bbc5a66a87b18d (diff) | |
| download | uskel-1909e97d4615045e707710a2aaeae8bf702a8355.tar.gz uskel-1909e97d4615045e707710a2aaeae8bf702a8355.tar.bz2 | |
Merge branch 'gc-attempt-1'
Diffstat (limited to 'sum.s')
| -rw-r--r-- | sum.s | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ + + +.include "include/uskel.s" + +.include "include/data.s" +.include "include/io.s" +.include "include/intops.s" + +.primop1 sumn + needs_alloc $0110 + + mov 010(%rsi), %rax + test %rax, %rax + jz sumn_zero + + dec %rax + thunkto %r10, $INT_code, %rax + thunkto %r10, $sumn, $1, %r10 + thunkto %r10, $plus, $2, %rsi, %r10 #TODO try the other way? + primop1_cont_indirect %r10 + + sumn_zero: + primop1_ret_int $0 + +# || -> cont +.thunkcode main + needs_alloc $0160 + # push a new integer + thunkto %r11, $INT_code, $10000000 + + # push the plus + thunkto %r11, $sumn, $1, %r11 + + # push the print + thunkto %r11, $print, $1, %r11 + + # push a cont thunk for main_exit + thunkto %rsi, $main_exit, $0 + + # evaluate into main_exit + enter %r11 + +.include "include/main_exit.s" |
