summaryrefslogtreecommitdiff
path: root/tnslc/utils
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-08-07 04:09:14 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-08-07 04:09:14 -0400
commit85daa32c72485272093804329851a56ca2ef9307 (patch)
tree1f3353fc61b1bf4a40e4e2144e8244a924ae1291 /tnslc/utils
parent248fe38d3e2d932001a950b554c731f1698727f9 (diff)
[tnslc] Fix indexing post-op, segfault when printing c formatted strings in tokens
Diffstat (limited to 'tnslc/utils')
-rw-r--r--tnslc/utils/c_wrap_linux.tnsl15
1 files changed, 11 insertions, 4 deletions
diff --git a/tnslc/utils/c_wrap_linux.tnsl b/tnslc/utils/c_wrap_linux.tnsl
index 70b50f0..97a93ba 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, lseek, perror"
+asm "extern malloc, realloc, free, printf, putchar, open, close, read, write, lseek, perror"
{}uint8 _alert = "Alert!\n\0"
{}uint8 _dec = "%d\n\0"
@@ -77,7 +77,7 @@ asm "extern malloc, realloc, free, printf, open, close, read, write, lseek, perr
# there's no more to do 'cause free returns nothing
;/
-/; _printf (~void str)
+/; _putchar (uint8 char)
asm "mov rax, rsp"
asm "xor rdx, rdx"
@@ -92,9 +92,16 @@ asm "extern malloc, realloc, free, printf, open, close, read, write, lseek, perr
asm "xor rax, rax"
# do call
- asm "call printf wrt ..plt"
+ asm "call putchar wrt ..plt"
- # there's no more to do 'cause printf returns nothing
+ # there's no more to do 'cause I don't care about putchar's output
+;/
+
+# wrap around putchar ( I was dumb and was using printf when I shouldn't have been )
+/; _printf (~uint8 str)
+ /; loop (str` !== 0) [str++]
+ _putchar(str`)
+ ;/
;/
/; _print_num (~void str, int num)