aboutsummaryrefslogtreecommitdiff
path: root/apply.s
blob: b8df87320f7a8389590ff246637271c0ce164498 (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

.include "include/uskel.s"

.include "include/apply.s"
.include "include/intops.s"
.include "include/io.s"
.include "include/main_exit.s"

.thunkcode theplus
	mov %rsi, %rbp
	thunkto %rsi, $FUN2_code, $plus, $0
	enter_rbp

.thunkcode main
	# make an integer
	thunkto %r11, $INT_code, $1

	# make an empty closure for adding stuff
	#thunkto %r12, $FUN2_code, $plus, $0 # this had less indirection
	thunkto %r12, $theplus, $0

	# apply first argument
	thunkto %r12, $apply, $2, %r12, %r11

	# apply second argument (the p.a. function part is still in r12)
	thunkto %r12, $apply, $2, %r12, %r11

	# print the result
	thunkto %r12, $print, $1, %r12

	# make a continuation for main (exit) and set it for print call
	thunkto %rsi, $main_exit, $0

	# start evaluating the print
	enter %r12