This is a card in Dave's Virtual Box of Cards.

Register Forth

Created: 2022-10-22

Thinking out loud here.

x86-64 gives us more general-purpose registers to work with. Given this, I think it would be neat to write a little Forth-like that uses registers explicitly rather than a stack.

I’m positive this is not an original idea (for example, I know a common Forth optimization is to always have at least the first stack item in a register). But I’d like to try it on my own just to get a feel for what it would be like to design such a thing.

I think it would be really interesting to try to figure out how to make it clear what each word uses a register for, and how to automate MOV between registers to get everything lined up for each word?

Each time I think about it, the complexity quickly spirals out of control!

Previous thoughts on register use: named-register-passing