aboutsummaryrefslogtreecommitdiff
path: root/sumac.s
blob: d53382c58ef27533f52f6d14aa00a9d6eb2df984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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"