romforth is a dialect of Forth which is meant to be easily portable.
I recently completed the port of romforth to the IBM 1130.
The IBM 1130 holds a special place in Forth history since it was one of the earliest systems on which Chuck Moore, the creator of Forth prototyped his initial/first(?) version, all the way back in 1968.
The IBM 1130 was in existence even before I was born so it was an interesting experience to wrap my head around figuring out how to implement things that we take for granted nowadays such as a stack pointer, call stacks and recursion. (I guess the lack of recursion in the early Fortran compilers can be directly attributed to this architecture). I'll use this blog entry to compare the version I came up with, to the version that Chuck implemented. A version of Chuck Moore's code which he wrote while working on an IBM 1130 at Mohasco, transcribed from a printed paper listing is available on github (thanks to Ken Boak for his work getting this code online and Perplexity for actually finding that Github repo for me).
From a quick/cursory look at the older code the following are some of the main differences that I noticed between his implementation and mine:
- It looks like he used indirect threading while I implemented a direct thread inner interpreter (in my PORTING guide these are denoted as type 1 vs type 2)
- He assumes an OS (or at least some library routines) while my implementation is baremetal (including my own interrupt handlers).
- There are a bunch of primitives (which can be identified by "B I <foo>") and some are recognizable (INC, NEXT etc) but like many Forth implementations the entire thing seems to be coded in assembly. Unlike that approach, I use a limited set of primitives coded in assembly over which everything else is layered as machine independent code. Quite obviously, I have ~60 years of hindsight (and Chuck's own later experiments) to draw on.
- Chuck Moore used the IBM 1130's index registers to implement the data and return stacks and my implementation uses exactly the same approach except that I kept the TOS at a separate memory location away from the stack.
- A C-struct like approach is used in his code to keep all of the interpreter context in one place whereas my code uses a completely different memory layout. Note that Forth predates C so this may have been an 1130'ism.
- I don't see the implementation of arithmetic ops - but I only took a cursory look at the code. I may review it again later if it looks interesting.
- The library routine DISK1 seems to be used for input/block read and PRNT1 seems to be used for output. I'm unfamiliar with these library routines so I can't say much more about it.
I'll leave it to the experts in IBM 1130 assembler to dig deeper into his code,
if they wish, especially since it's just a git clone away.