aboutsummaryrefslogtreecommitdiff
path: root/apply.s
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-08-11 22:30:22 +0200
committerMirek Kratochvil <exa.exa@gmail.com>2023-08-11 22:30:22 +0200
commit5184299c7dfddeba4d2d2ba95d390040368f9736 (patch)
treee3debfdc11073435a5459266d6dcec61b1fc30b1 /apply.s
parent74cad993376dc269e8389fbf150be9ecc36890c7 (diff)
downloaduskel-5184299c7dfddeba4d2d2ba95d390040368f9736.tar.gz
uskel-5184299c7dfddeba4d2d2ba95d390040368f9736.tar.bz2
ap aps
Diffstat (limited to 'apply.s')
-rw-r--r--apply.s47
1 files changed, 47 insertions, 0 deletions
diff --git a/apply.s b/apply.s
new file mode 100644
index 0000000..21a1efc
--- /dev/null
+++ b/apply.s
@@ -0,0 +1,47 @@
+
+.include "include/uskel.s"
+
+.include "include/apply.s"
+.include "include/intops.s"
+.include "include/io.s"
+.include "include/main_exit.s"
+
+main:
+ # make an integer
+ pushq $1
+ pushq $INT_code
+ mov %rsp, %r11
+
+ # make a closure for adding stuff
+ pushq $0
+ pushq $plus
+ pushq $FUN2_code
+ mov %rsp, %r12
+
+ # apply first argument
+ push %r11
+ push %r12
+ pushq $2
+ pushq $apply1
+ mov %rsp, %r12
+
+ # apply second argument (the p.a. function part is still in r12)
+ push %r11
+ push %r12
+ pushq $2
+ pushq $apply1
+ mov %rsp, %r12
+
+ # print the result
+ push %r12
+ pushq $1
+ pushq $print
+ mov %rsp, %r12
+
+ # make the continuation for main (exit)
+ push %rsi
+ pushq $1
+ pushq $main_exit
+
+ mov %rsp, %rsi
+ enter %r12