summaryrefslogtreecommitdiff
path: root/sanctuary.fs
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-24 23:23:19 +1100
committerkitty <nepeta@canaglie.net>2026-03-24 23:23:19 +1100
commit839e3510d3ad5bece904001a76d65901664ec4da (patch)
tree635363f9b365205a3a181ad414cd4c2519b5e0c1 /sanctuary.fs
parent6819ca743193bb9ae4e32c9c87c98b27d06c0c82 (diff)
zstrings and the worst hack in the universe
Diffstat (limited to 'sanctuary.fs')
-rw-r--r--sanctuary.fs13
1 files changed, 13 insertions, 0 deletions
diff --git a/sanctuary.fs b/sanctuary.fs
index 2715912..c420890 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -61,6 +61,12 @@
branch >mark >r 2dup cmove, nip ( u ) ( R: mark )
r> dup >resolve 4 + ( u a )
postpone literal ( a ) postpone literal ( u ) ; immediate compile-only
+: z" [ char " ] literal parse ( a u )
+ branch >mark >r 2dup cmove, 0 c, nip ( u ) ( R: mark )
+ r> dup >resolve 4 + ( u a )
+ postpone literal ( a ) drop ; immediate compile-only
+: zstrlen dup begin dup c@ 0<> while 1+ repeat swap - ;
+: s>z here -rot cmove, 0 c, ;
1 constant stdout
2 constant stderr
@@ -68,4 +74,11 @@
: type swap stdout 1 syscall3 ;
: emit sp 1 swap stdout 1 syscall3 2drop ;
+hex
+\ really i should just change the builtins to work with defer
+: hijacks ' ( word ) here >r dp ! ( temporarily set dp so we can use , )
+ 49 c, bb c, ( xt ) , \ mov r11, xt
+ 41 c, ff c, e3 c, \ jmp r11
+ r> dp ! ;
+decimal
bye