aboutsummaryrefslogtreecommitdiff
path: root/sum.s
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-10-31 21:07:03 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2023-10-31 21:07:03 +0100
commitfbc57cad5622039654b95590ab1efb464984c71b (patch)
treebcc251ff37486ae297615723faf45bbb5e92bedb /sum.s
parent2bc3d9a3815a6cd172b3b4f7696c46a006021b13 (diff)
downloaduskel-fbc57cad5622039654b95590ab1efb464984c71b.tar.gz
uskel-fbc57cad5622039654b95590ab1efb464984c71b.tar.bz2
debug the gc
Diffstat (limited to 'sum.s')
-rw-r--r--sum.s43
1 files changed, 43 insertions, 0 deletions
diff --git a/sum.s b/sum.s
new file mode 100644
index 0000000..4cc709f
--- /dev/null
+++ b/sum.s
@@ -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"