diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-12 15:12:03 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-12 15:12:03 +0200 |
| commit | 6be5a28bb90b391a5842a8ce3dfc7c154100ab68 (patch) | |
| tree | 22e04a263e68d983c6bf5d1fdebd662e66915e96 /fibs.s | |
| parent | 5184299c7dfddeba4d2d2ba95d390040368f9736 (diff) | |
| download | uskel-6be5a28bb90b391a5842a8ce3dfc7c154100ab68.tar.gz uskel-6be5a28bb90b391a5842a8ce3dfc7c154100ab68.tar.bz2 | |
make a macro for pushing out thunks
Diffstat (limited to 'fibs.s')
| -rw-r--r-- | fibs.s | 67 |
1 files changed, 14 insertions, 53 deletions
@@ -9,26 +9,15 @@ # | lag1 | lag2 | -> cont .thunkcode fibs # next value - pushq 030(%rbp) - pushq 020(%rbp) - pushq $2 - pushq $plus - mov %rsp, %r11 + thunkto %r11, $plus, $2, 020(%rbp), 030(%rbp) # fib call with the next value - push %r11 - pushq 030(%rbp) - pushq $2 - pushq $fibs - mov %rsp, %r12 + thunkto %r12, $fibs, $2, 030(%rbp), %r11 - # cons list with lag1 - push %r12 - push 020(%rbp) - pushq $1 - pushq $LIST_code - mov %rsp, %r13 + # cons list with the lagged arg + thunkto %r13, $LIST_code, $1, 020(%rbp), %r12 + # TODO simplify # replace self with IND mov %r13, 010(%rbp) movq $IND_code, 0(%rbp) @@ -39,43 +28,15 @@ # || -> cont .thunkcode fibs0 - pushq $1 - pushq $INT_code - mov %rsp, %r12 - pushq $0 - pushq $INT_code - mov %rsp, %r11 - - push %r12 - push %r11 - pushq $2 - pushq $fibs - - enter %rsp + thunkto %r12, $INT_code, $1 + thunkto %r11, $INT_code, $0 + thunkto %rbp, $fibs, $2, %r11, %r12 + enter_rbp .thunkcode main - pushq $0 - pushq $fibs0 - mov %rsp, %r12 - - pushq $20 - pushq $INT_code - mov %rsp, %r11 - - push %r12 - push %r11 - pushq $2 - pushq $list_int_index - mov %rsp, %r11 - - push %r11 - pushq $1 - pushq $print - mov %rsp, %r11 - - push %rsi - pushq $1 - pushq $main_exit - - mov %rsp, %rsi + thunkto %r12, $fibs0, $0 + thunkto %r11, $INT_code, $20 + thunkto %r11, $list_int_index, $2, %r11, %r12 + thunkto %r11, $print, $1, %r11 + thunkto %rsi, $main_exit, $1, %rsi enter %r11 |
