aboutsummaryrefslogtreecommitdiff
path: root/include/listops.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 /include/listops.s
parent46d84e91ebe48ade19bd3f5e18360bf853b53968 (diff)
downloaduskel-74cad993376dc269e8389fbf150be9ecc36890c7.tar.gz
uskel-74cad993376dc269e8389fbf150be9ecc36890c7.tar.bz2
fibs work
Diffstat (limited to 'include/listops.s')
-rw-r--r--include/listops.s40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/listops.s b/include/listops.s
new file mode 100644
index 0000000..eb8f6cf
--- /dev/null
+++ b/include/listops.s
@@ -0,0 +1,40 @@
+
+.ifndef _listops_s_file
+_listops_s_file:
+
+.include "include/primops.s"
+
+# | n | list | -> cont
+.primop2 list_int_index
+ mov 010(%rsi), %rdx # the list constructor id, must be 1
+ cmp $1, %rdx
+ jne list_int_index_not_found
+
+ mov 020(%rbp), %rcx
+ mov 010(%rcx), %rcx
+ test %rcx, %rcx
+ jz list_int_index_found #we are taking 0, all happy, return it
+
+ #more probably we need to continue, make replacement thunks
+ sub $1, %rcx
+ pushq %rcx
+ pushq $INT_code
+ mov %rsp, %r11
+
+ pushq 030(%rsi) # tail
+ push %r11
+ pushq $2
+ pushq $list_int_index
+ mov %rsp, %r11
+
+ primop2_cont_indirect %r11
+
+list_int_index_not_found:
+ movq 0, %rax #fault
+
+list_int_index_found:
+ mov 020(%rsi), %rax #head
+ primop2_cont_indirect %rax
+
+
+.endif # _listops_s_file