From 5184299c7dfddeba4d2d2ba95d390040368f9736 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Fri, 11 Aug 2023 22:30:22 +0200 Subject: ap aps --- apply.s | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 apply.s (limited to 'apply.s') 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 -- cgit v1.2.3