aboutsummaryrefslogtreecommitdiff
path: root/fibs.s
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-08-06 00:25:53 +0200
committerMirek Kratochvil <exa.exa@gmail.com>2023-08-06 00:25:53 +0200
commit74cad993376dc269e8389fbf150be9ecc36890c7 (patch)
tree32a2dbb382836ee0f1853fe5e63036d044fea77d /fibs.s
parent46d84e91ebe48ade19bd3f5e18360bf853b53968 (diff)
downloaduskel-74cad993376dc269e8389fbf150be9ecc36890c7.tar.gz
uskel-74cad993376dc269e8389fbf150be9ecc36890c7.tar.bz2
fibs work
Diffstat (limited to 'fibs.s')
-rw-r--r--fibs.s81
1 files changed, 81 insertions, 0 deletions
diff --git a/fibs.s b/fibs.s
new file mode 100644
index 0000000..c32f424
--- /dev/null
+++ b/fibs.s
@@ -0,0 +1,81 @@
+
+.include "include/uskel.s"
+
+.include "include/listops.s"
+.include "include/intops.s"
+.include "include/io.s"
+.include "include/main_exit.s"
+
+# | lag1 | lag2 | -> cont
+.thunkcode fibs
+ # next value
+ pushq 030(%rbp)
+ pushq 020(%rbp)
+ pushq $2
+ pushq $plus
+ mov %rsp, %r11
+
+ # fib call with the next value
+ push %r11
+ pushq 030(%rbp)
+ pushq $2
+ pushq $fibs
+ mov %rsp, %r12
+
+ # cons list with lag1
+ push %r12
+ push 020(%rbp)
+ pushq $1
+ pushq $LIST_code
+ mov %rsp, %r13
+
+ # replace self with IND
+ mov %r13, 010(%rbp)
+ movq $IND_code, 0(%rbp)
+
+ mov %rsi, %rbp
+ mov %r13, %rsi
+ enter_rbp
+
+# || -> 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
+
+.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
+ enter %r11