aboutsummaryrefslogtreecommitdiff
path: root/sumac.s
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-11-01 18:25:06 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2023-11-01 18:25:06 +0100
commit970ffb4684dbd88bd54e909820bbc5a66a87b18d (patch)
tree43ad1d8438ef824deaf6d363d38f5d60f3d04645 /sumac.s
parentd1a4eb56ccf39974dd93eeb0434721acc69bbc7c (diff)
downloaduskel-970ffb4684dbd88bd54e909820bbc5a66a87b18d.tar.gz
uskel-970ffb4684dbd88bd54e909820bbc5a66a87b18d.tar.bz2
all looks ok
Diffstat (limited to 'sumac.s')
-rw-r--r--sumac.s40
1 files changed, 40 insertions, 0 deletions
diff --git a/sumac.s b/sumac.s
new file mode 100644
index 0000000..d53382c
--- /dev/null
+++ b/sumac.s
@@ -0,0 +1,40 @@
+
+
+.include "include/uskel.s"
+
+.include "include/data.s"
+.include "include/io.s"
+.include "include/intops.s"
+
+.primop2 sumac
+ needs_alloc $0100
+
+ mov 020(%rbp), %rdi #1st arg
+ mov 010(%rdi), %rcx #1st arg val
+ mov 010(%rsi), %rax #2nd arg val
+
+ cmp $0, %rcx
+ jz sumac_ret
+
+ add %rcx, %rax
+ dec %rcx
+ thunkto %r10, $INT_code, %rcx
+ thunkto %r11, $INT_code, %rax
+ thunkto %r10, $sumac, $2, %r10, %r11
+ primop2_cont_indirect %r10
+
+ sumac_ret:
+ primop2_ret_int %rax
+
+.thunkcode main
+ needs_alloc $0150
+
+ thunkto %r11, $INT_code, $10000000
+ thunkto %r12, $INT_code, $0
+ thunkto %r11, $sumac, $2, %r11, %r12
+
+ thunkto %r11, $print, $1, %r11
+ thunkto %rsi, $main_exit, $0
+ enter %r11
+
+.include "include/main_exit.s"