From b42d8229a09103623f421937f217b8cc8609e06b Mon Sep 17 00:00:00 2001 From: kitty Date: Wed, 21 Jan 2026 16:17:18 +1100 Subject: move to STC forth, note on COMPILE, --- readme.md | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'readme.md') diff --git a/readme.md b/readme.md index 03b19f0..5d6ab77 100644 --- a/readme.md +++ b/readme.md @@ -5,18 +5,31 @@ if you use it and it breaks, too bad public domain -the plan right now is that this will be a DTC forth. -while an STC forth would be nice -(being able to mix assembly and forth would be nice) -having to manually compile in bytes would be annoying. -maybe one day i will do an STC forth... +the plan right now is that this will be an STC forth. +if this proves Too Complicated To Deal With the plan may be changed +to a DTC forth instead. ## forth registers there are a set of 'virtual registers' (see moving forth part 1) - W, the working register, is r11. - X, the secondary working register, is r12. -- IP, the instruction pointer, is r13. +- IP, the instruction pointer, is r13. (this will only be needed if we switch to DTC, otherwise this can be Y, a third general purpose register) - SP, the working stack pointer, is r14. -- RSP, the return stack pointer, is rsp. - TOS, the top of the stack, is r15. +- RSP, the return stack pointer, is rsp. + +on SP (r14): note that since TOS is kept in a register, +SP points to the *second* item in the stack. + +## miscellaneous notes and stuff + +### COMPILE, +this is an STC forth so when we compile a call we have to +write the bytes of a `call` in manually. +x86\_64 does not allow absolute jumps from an immediate address, +so a wonky but hopefully not too slow solution is to compile +`literal address → W` and then `call W`. It'll Be Fine? + +- `mov r11, [cfa] = `94 BB [CFA]` +- `call r11` = `41 FF D3` -- cgit v1.2.3