summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jefs.fs2
-rw-r--r--jefs.s63
2 files changed, 62 insertions, 3 deletions
diff --git a/jefs.fs b/jefs.fs
index e9c3119..0999962 100644
--- a/jefs.fs
+++ b/jefs.fs
@@ -16,6 +16,7 @@ decimal
: [compile] parse find drop >cfa compile, ; immediate
: ' parse find drop >cfa [compile] lit ; immediate \ note: no error handling (yet)
+: literal [compile] lit ; immediate
: constant create [compile] lit ret, ;
: variable 1 cells allot create [compile] lit ret, ;
@@ -29,6 +30,7 @@ decimal
: / /mod swap drop ;
: mod /mod drop ;
+: s" [ char " ] literal >in @ 1 + >in ! ( skip spc ) [compile] litstring ; immediate
: testing 0 if TESTSTR else TESTSTR2 then say cr ;
testing bye
diff --git a/jefs.s b/jefs.s
index e64a182..5d5496c 100644
--- a/jefs.s
+++ b/jefs.s
@@ -560,14 +560,70 @@ defword "lit", lit, immediate_mask ; C: ( n -- ) ( -- n )
defword "litstring", litstring, immediate_mask ; I: ( delim -- )
pspop r11 ; delim
mov r12, [here]
+ mov r13, qword [to_in]
+ add r13, qword [tib]
mov byte [r12], 0xe9 ; JMP
inc r12
- push r12
+ push r12 ; place to write to later (32bit)
mov dword [r12], 0x00000000 ; filler value
- ; hm,, is the relative value gonna be equivalent to strlen + 1?
+ add r12, 4
+
+ xor r10, r10 ; count
+.loop:
+ mov r15b, byte [r13]
+
+ cmp r15b, r11b
+ je .done
+
+ mov byte [r12], r15b
+
+ inc r10 ; count
+ inc r12 ; here
+ inc r13 ; >in
+ jmp .loop
+
+.done:
+ ; put back r13, we're done reading from tib
+ inc r13
+ sub r13, qword [tib]
+ mov qword [to_in], r13
+
+ ; repurpose r13 as reljmp write location
+ pop r13
+ inc r10 ; jump strlen + 1 bytes forward
+ mov dword [r13], r10d
+ dec r10
+
+ add r13, 4 ; r13 + 4 = string location
+
+ ; copied from LIT (which consumes r12)
+ ; we copy it here because then we keep using
+ ; theh same r12 as we were before
+ ; bit long but i think it's Fine
+ ; i'm not rlly worried about code size
+ mov dword [r12], 0xf8768d4d
+ add r12, 4
+ mov word [r12], 0xbb49
+ add r12, 2
+ mov qword [r12], r13 ; addr
+ add r12, 8
+ mov word [r12], 0x894d
+ add r12, 2
+ mov byte [r12], 0x1e
+ inc r12
+
+ mov dword [r12], 0xf8768d4d
+ add r12, 4
+ mov word [r12], 0xbb49
+ add r12, 2
+ mov qword [r12], r10 ; slen
+ add r12, 8
+ mov word [r12], 0x894d
+ add r12, 2
+ mov byte [r12], 0x1e
+ inc r12
- pop r12
mov qword [here], r12
ret
@@ -920,6 +976,7 @@ defword "HEREDUMP", heredump, 0
; }}}
defvar "tib", tib, 0, initfile
+defvar "#tib", num_tib, 0, initlen
defvar ">in", to_in, 0, 0
defvar "state", state, 0, interpreting
defvar "here", here, 0, umem