From 6be5a28bb90b391a5842a8ce3dfc7c154100ab68 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 12 Aug 2023 15:12:03 +0200 Subject: make a macro for pushing out thunks --- apply.s | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'apply.s') diff --git a/apply.s b/apply.s index 21a1efc..2d7109d 100644 --- a/apply.s +++ b/apply.s @@ -8,40 +8,22 @@ main: # make an integer - pushq $1 - pushq $INT_code - mov %rsp, %r11 + thunkto %r11, $INT_code, $1 - # make a closure for adding stuff - pushq $0 - pushq $plus - pushq $FUN2_code - mov %rsp, %r12 + # make an empty closure for adding stuff + thunkto %r12, $FUN2_code, $plus, $0 # apply first argument - push %r11 - push %r12 - pushq $2 - pushq $apply1 - mov %rsp, %r12 - + thunkto %r12, $apply1, $2, %r12, %r11 + # apply second argument (the p.a. function part is still in r12) - push %r11 - push %r12 - pushq $2 - pushq $apply1 - mov %rsp, %r12 + thunkto %r12, $apply1, $2, %r12, %r11 # print the result - push %r12 - pushq $1 - pushq $print - mov %rsp, %r12 + thunkto %r12, $print, $1, %r12 - # make the continuation for main (exit) - push %rsi - pushq $1 - pushq $main_exit + # make a continuation for main (exit) and set it for print call + thunkto %rsi, $main_exit, $1, %rsi - mov %rsp, %rsi + # start evaluating the print enter %r12 -- cgit v1.2.3