From 970ffb4684dbd88bd54e909820bbc5a66a87b18d Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Wed, 1 Nov 2023 18:25:06 +0100 Subject: all looks ok --- sumac.s | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sumac.s (limited to 'sumac.s') 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" -- cgit v1.2.3