diff options
| author | kitty <nepeta@canaglie.net> | 2026-03-15 15:55:08 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-03-15 15:55:08 +1100 |
| commit | fe2443a10773bfa1890342fc4240e9da71ff7527 (patch) | |
| tree | 6354334797ffbe7a4ee848f3ca69bc068ba796d1 | |
| parent | 726c1087c1a52a1fb4799ea6130b10182ed2222a (diff) | |
some macros
| -rw-r--r-- | readme.md | 18 | ||||
| -rw-r--r-- | sanctuary.s | 46 |
2 files changed, 63 insertions, 1 deletions
@@ -12,6 +12,7 @@ for amd64 linux systems. - `?`: boolean flag ## Glossary + the following is a list of words available in this forth. (neither of these have been implemented yet i'm just putting them here in the meantime lol) ### `dp ( -- a )` @@ -20,3 +21,20 @@ the following is a list of words available in this forth. (neither of these have ### `here ( -- a )` `here` yields the address of the first available byte in user memory. + +## dictionary format + +note that the string length of one byte limits a word's name to 255 characters. + +| field | size | +| :---- | :--- | +| link to previous word | 8 bytes | +| flag field | 1 byte | +| string length | 1 byte | +| string | <256 bytes | +| code | variable length | + +## reserved registers + +the registers `r14` and `r15` are reserved for the parameter stack +and the top of stack respectively. diff --git a/sanctuary.s b/sanctuary.s index ad8720f..5859ac1 100644 --- a/sanctuary.s +++ b/sanctuary.s @@ -1,7 +1,51 @@ ; sanctuary -section .bss +; macros {{{ +; in this forth pspush and pspop are only necessary if you need to +; go deeper into the stack. +; TODO: error handling (once i add that) +%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 + +%define s_latest 0 + +%macro defdict 3 ; name label flags + %strlen slen %1 + global lfa_%2 + lfa_%2: dq s_latest + %define s_latest lfa_%2 + ffa_%2: db %3 + nfa_%2: db slen + db %1 +%endmacro +%macro defcode 3 + defdict %1, %2, %3 + %2: +%endmacro + +; this is just taken from jewelforth, and does not correspond +; to how user variables are planned to work in sanctuary +; so todo make better later? i don't know if it really matters +; because it will only apply to builtin variables. +%macro defvar 3 + %2: dq %4 + defdict %1, %2, %3 + ; pspush qword %2 ; todo + %2: +%endmacro +; }}} + +section .bss resq 4091 wstk: resq 1 |
