From 5d688b4da97da2c2f684940147478f12d1f2baba Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 19 Jul 2024 03:21:39 -0400 Subject: switch tokenization scheme --- tnslc/utils/c_wrap_linux.tnsl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tnslc/utils/c_wrap_linux.tnsl') 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 -- cgit v1.2.3