summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jefs.s66
-rw-r--r--readme.md6
2 files changed, 62 insertions, 10 deletions
diff --git a/jefs.s b/jefs.s
index 8af3ab7..78ee14b 100644
--- a/jefs.s
+++ b/jefs.s
@@ -22,7 +22,6 @@
ffa_%2: db %3 ; FFA
nfa_%2: dw slen ; NFA
db %1
- db 0
%endmacro
%macro defword 3
@@ -162,7 +161,6 @@ defword "parse", parse, 0
pspush r11 ; u
ret
-; probably fucked up and broken. have not tested any of this yet
defword "find", find, 0
pspop r10 ; u
pspop r11 ; c-addr
@@ -210,23 +208,46 @@ defword "interpret", interpret, 0
call parse
call find
pspop r11 ; assume it exists its fine for now
- call to_cfa
mov r12, qword [state]
cmp r12, compiling
je .compile
.interp:
+ call to_cfa
pspop r11
call r11
jmp .loop
ret ; unreachable safety RET
.compile:
+ ; handle immediates
+ call dup
+ call immediate_q
+ pspop r13
+ cmp r13, true
+ je .interp
+
+ call to_cfa
pspop r11
call compile_comma
jmp .loop
ret ; unreachable safety RET
+defword "immediate?", immediate_q, 0 ; ( lfa -- flag )
+ pspop r11
+ add r11, 8
+ mov r12b, byte [r11]
+ test r12b, immediate_mask
+ jnz .imm
+
+ mov r11, false
+ pspush r11
+ ret
+
+.imm:
+ mov r11, true
+ pspush r11
+ ret
defword ">cfa", to_cfa, 0
pspop r11
@@ -235,7 +256,6 @@ defword ">cfa", to_cfa, 0
mov r12w, word [r11]
add r11, 2
add r11, r12
- inc r11
pspush r11
ret
@@ -259,9 +279,42 @@ defword "compile,", compile_comma, 0
ret
defword ":", colon, 0
+ call parse
+ pspop r9 ; u
+ pspop r10 ; c-addr
+ mov r11, [latest]
+ mov r12, [here]
+ push r12 ; keep for LATEST
+
+ mov qword [r12], r11
+ add r12, 8
+ mov byte [r12], smudge_mask
+ inc r12
+ mov word [r12], r9w ; r9w from r9: safe?
+ add r12, 2
+
+ ; strcpy
+ mov rcx, r9
+ mov rsi, r10
+ mov rdi, r12
+ rep movsb
+ add r12, r9
+
+ mov qword [here], r12
+ pop r12
+ mov qword [latest], r12
ret
defword ";", semicolon, immediate_mask
+ ; unsmudge
+ mov r12, [latest]
+ add r12, 8
+ mov r13b, [r12]
+ mov r15b, smudge_mask ; todo figure out how to do this at assemble time
+ not r15b
+ and r13b, r15b
+ mov byte [r12], r13b
+
mov r11, [here]
mov byte [r11], 0xc3
inc r11
@@ -269,6 +322,11 @@ defword ";", semicolon, immediate_mask
mov qword [state], interpreting
ret
+defword "dup", dup, 0
+ mov r11, [r14]
+ pspush r11
+ ret
+
defvar ">in", to_in, 0, 0
defvar "state", state, 0, interpreting
defvar "here", here, 0, 0
diff --git a/readme.md b/readme.md
index 5670e58..9938f7d 100644
--- a/readme.md
+++ b/readme.md
@@ -18,17 +18,11 @@ the dictionary follows a fairly standard format.
| flag | 1 byte | FFA (flag field address) |
| string length | 2 bytes | NFA (name field address) |
| string | variable length | still NFA |
-| null byte | 1 byte |
| code | variable length | CFA (code field address) |
probably, some bitmask antics could be done to store the string length
and flags together. but alternatively: no.
-the stored string is a counted string but also has a
-null byte at the end. bit of a waste of space but i can use
-x86's `repz` for it. maybe there is a counted string version
-though, i don't know
-
## forth registers
- the working stack pointer, is `r14`.