Page 1 of 1

A recommended Forth for OSDev

Posted: Sat Mar 05, 2022 9:26 am
by Flamore
Hi all, is there a Forth implementation that's preferably cross platform, which would allow me to compile into a bin so i can start with OSDev? I'm mainly aiming for the x86 but if it supports more than that then i'll gladly take it. It doesn't really have to be an implementation, if it generates a bin then it's enough. :D

Re: A recommended Forth for OSDev

Posted: Sun Mar 13, 2022 2:50 am
by eekee
Flamore wrote:Hi all, is there a Forth implementation that's preferably cross platform, which would allow me to compile into a bin so i can start with OSDev? I'm mainly aiming for the x86 but if it supports more than that then i'll gladly take it. It doesn't really have to be an implementation, if it generates a bin then it's enough. :D
I feel like ought to know the answer to this, but it's just different enough from my goals that I don't. :) I want an interactive Forth where most of the system remains in source code form, so I've hardly looked at compilers. At the moment, I'm planning on using the built-in Forth interpreter in the OpenFirmware of an old Mac just to have a bit of fun. I'd ask in a Forth community; you'll get more knowledgable answers. Running Forth on bare hardware used to be common and there are many free Forth implementations, often licensed to the public domain, some of which compile their own kernel to binary. They differ a lot in features, including language features, so you might have to try a few to find a suitable one.

What sort of features would you want for an OS? Language features are up to you, their usefulness depends on how you code. Many Forths have a built-in assembler; I think that would be good for OS dev, or actually essential if you want to generate a binary straigth from Forth. (If you use a linker, you can use a separate assembler.) Lots of Forths want to load their initial dictionary from a file, but in general, it wouldn't be hard to hack them into bootable form. How about word size? For the PC, there may be more 16-bit than 32-bit Forths, and 64-bit I don't know about at all.

I have thought about using Pygmy Forth for DOS. (Not Pygmy64 which depends on Python.) It's 16-bit and non-standard, but remarkable for its small code size and clean design. It's so small, it doesn't even bother with segments, but you can figure out how to add them from its video code. (It looks like it recycles the right parentheses for variable fetching in assembler, outside of comments.) I didn't use it because it doesn't have some language features I thought I wanted, but now I'm not so sure I want them anyway.