-
Notifications
You must be signed in to change notification settings - Fork 0
A Forth. Mirror of the primary hg repo at https://hg.sr.ht/~nbuwe/forth
nbuwe/forth
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a very simple Forth that uses dumb, honest to god indirect threaded code. The core is written entirely in assembler. There are only three environmental dependencies for now - printing one char (EMIT), printing a buffer (TYPE) and reading an input line (ACCEPT). Escape to C is also used for things like 64-bit division (rewriting __divmoddi4 in asm from scratch is boring and kinda pointless). Currently supported CPUs: arm, i386, powerpc, sh3. The core of the interpreter for sh3 is 14 instructions (two of which are nops in delay slots). About 90 asm words tally up to about 500 instructions. Nearly all of them are short trivial sequences, like adding two numbers, etc. I'd say that someone familiar with the target ISA can port == write the asm core in two or three evenings. I wrote powerpc code in three evenings without any prior knowledge of the ISA. The ARM port was done on a branch with a lot of small commits specifically to illustrate the process and can be used as a reference. The rest of the system is transpiled from the forth sources to MI assembler sources. That "compiled" assembler used to be handwritten (and you can still find it on the "handwritten" branch), but as the system grows it gets more inconvenient to maintain it in that form. Generating assembler source is not the most convenient way to go about making a forth system. Still there are certain reasons that make the tradeoffs worthwhile for me. GNU assembler is single pass, so that imposes certain limitations. There's a strong temptation to throw M4 into the mix to fix that, but M4 introduces certain inconveniences of its own and I'm still not desperate enough to accept them. -uwe
About
A Forth. Mirror of the primary hg repo at https://hg.sr.ht/~nbuwe/forth
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published