summaryrefslogtreecommitdiff
path: root/tnslc/utils/c_wrap_linux.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-07-19 03:21:39 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-07-19 03:21:39 -0400
commit5d688b4da97da2c2f684940147478f12d1f2baba (patch)
treede7f4dff152249587790c2b07149769faaefaa37 /tnslc/utils/c_wrap_linux.tnsl
parent34e3d4f52264cf707f7e73a8a4167f37eee812d9 (diff)
switch tokenization scheme
Diffstat (limited to 'tnslc/utils/c_wrap_linux.tnsl')
-rw-r--r--tnslc/utils/c_wrap_linux.tnsl26
1 files changed, 25 insertions, 1 deletions
diff --git a/tnslc/utils/c_wrap_linux.tnsl b/tnslc/utils/c_wrap_linux.tnsl
index 814ec1c..1e3155e 100644
--- a/tnslc/utils/c_wrap_linux.tnsl
+++ b/tnslc/utils/c_wrap_linux.tnsl
@@ -1,5 +1,5 @@
# Must be included at the top of the file
-asm "extern malloc, realloc, free, printf, open, close, read, write"
+asm "extern malloc, realloc, free, printf, open, close, read, write, fseek"
{}uint8 _alert = "Alert!\n\0"
{}uint8 _dec = "%d\n\0"
@@ -202,6 +202,30 @@ asm "extern malloc, realloc, free, printf, open, close, read, write"
return out
;/
+/; _fseek (~void handle, uint pos) [int]
+ int out
+
+ # align stack
+ asm "mov rax, rsp"
+ asm "xor rdx, rdx"
+ asm "mov rcx, 16"
+ asm "div rcx"
+ asm "sub rsp, rdx"
+ # add buffer zone to stack
+ asm "sub rsp, 128"
+
+ # Call c func
+ asm "mov rdi, r10"
+ asm "mov rsi, r11"
+ asm "mov rdx, 0" # standard value for SEEK_SET as per GNU libc
+ asm "call fseek wrt ..plt"
+
+ # get return value
+ asm "mov r12, rax"
+
+ return out
+;/
+
/; _write_byte (~void handle, ~uint8 byte) [int]
int out