summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-01-22 13:05:14 +1100
committerkitty <nepeta@canaglie.net>2026-01-22 13:05:14 +1100
commitfdf1935e2cc4142bf1585a78844f5b7df0e1cd8f (patch)
treee85a145573843cb7c879828e081e2a414d90e13a
parent9ddee3df23c1abc39a5e0e0605c4f815db113e3e (diff)
some macros
-rw-r--r--jefs.s46
-rw-r--r--readme.md16
2 files changed, 54 insertions, 8 deletions
diff --git a/jefs.s b/jefs.s
index b9327dc..40ba54d 100644
--- a/jefs.s
+++ b/jefs.s
@@ -1,7 +1,53 @@
; jewelforth
;; MACROS {{{
+%macro pspush 1
+ lea r14, [r14-8]
+ mov qword [r14], r15
+ mov r15, %1
+%endmacro
+
+%macro pspop 1
+ mov %1, r15
+ mov r15, qword [r14]
+ lea r14, [r14+8]
+%endmacro
+
+;;; dictionary macros {{{
+%define mac_latest 0 ; updated through defdict
+
+%macro defdict 3 ; name asm-label flags
+ %strlen slen %1
+ global lfa_%2
+ lfa_%2: dq mac_latest
+ %define mac_latest lfa_%2
+ ffa_%2: db %3 ; FFA
+ nfa_%2: dw slen ; NFA
+ db %1
+%endmacro
+
+%macro defword 3
+ defdict %1, %2, %3
+ %2:
+%endmacro
+
+%macro defconst 4 ; ... value
+ defdict %1, %2, %3
+ %define %2 %4
+ pspush qword %4
+ ret
+%endmacro
+
+%macro defvar 4 ; ... default-value
+ %2: dq %4
+ defdict %1, %2, %3
+ pspush qword %2
+ ret
+%endmacro
+
%assign smudge_mask 0x1
+%assign immemdiate_mask 0x2
+;;; }}}
;; syscall
%assign __NR_read 0
diff --git a/readme.md b/readme.md
index d77c014..64af573 100644
--- a/readme.md
+++ b/readme.md
@@ -12,13 +12,13 @@ to a DTC forth instead.
## dictionary
the dictionary follows a fairly standard format.
-| field | size |
-| :---- | :--- |
-| link to previous | 8 bytes |
-| flag | 1 byte |
-| string length | 2 bytes |
-| string | variable length |
-| code | variable length |
+| field | size | forth name |
+| :---- | :--- | :--------- |
+| link to previous | 8 bytes | LFA (link field address) |
+| flag | 1 byte | FFA (flag field address) |
+| string length | 2 bytes | NFA (name field address) |
+| string | variable length | still NFA |
+| 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.
@@ -48,7 +48,7 @@ so a wonky but hopefully not too slow solution is to compile
- `mov r11, [cfa]` = `94 BB [CFA]`
- `call r11` = `41 FF D3`
-# Some Links
+## Some Links
- starting forth part 1: http://www.bradrodriguez.com/papers/moving1.htm
- a forum thread about determining empty stack with TOS register: http://forum.6502.org/viewtopic.php?t=8424