please dont rip this site

the Forth programming language

FORTH in general

specific Forth implementations


James Newton says:

Warning: Assembly code and bad memory

1000 years ago, when I was 17, I wrote a FORTH for the Z80 on a Trash 80. It was unique for the time, because it used the machine language RET as NEXT for asm words. e.g. the machine stack pointed NOT at the data stack or return stack but at the list of word addresses being executed; the thread. That meant that asm words could be strung together even faster than a standard asm program because there was no asm CALL... the RET was both the return from the current asm word AND the call to the next one. The address of the data and return stacks were kept elsewhere... one of the other registers or a memory location (I don't remember, code is long lost). I think it was IX and IY. Every non-asm word had to start with an asm call to a routine that saved SP to the return stack pointer, set the SP to the value on the stack and RET. If I remember, that's called THREAD? Then at the end, the last address was to an asm word that pulled the return stack TOS back into SP and RET. I seem to remember that is called NEXT. So for asm words, NEXT is RET and for higher level words, NEXT was a few asm instructions.

Advantages: /screaming/ fast low level words, no slower high level words.

Disadvantages: low level words couldn't really use the stack, because they would overwrite a thread. Of course, you could save and restore SP... but I seem to remember doing most manipulation of the stack with other registers. e.g. LD (IX+0),SP; INC IX; INC IX; Or maybe it was DEC, I don't remember.

And the big disadvantage: NO INTERRUPTS during asm words! LOL. Can't save PC to TOS because it would over write a thread. I got around that somewhat by adding an EI (enable interrupts) in the NEXT code while the SP was pointed at the return stack, doing a NOP and then DI. LOOP also had that in it because it was asm.

See also:

file: /Techref/language/forths.htm, 6KB, , updated: 2019/9/16 14:08, local time: 2020/2/21 16:24,

 ©2020 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> the FORTH programming language </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!