BYOK: Bare Metal Forth

BYOK forth running on i386 qemu VM
BYOK Forth running on bare metal x86(-64) desktop computer

Forth is a language that was designed to be run on bare-metal – without an underlying operating system. Some interesting quotes from Chuck Moore:

The operating system is another concept that is curious. Operating systems are dauntingly complex and totally unnecessary. It’s a brilliant thing that Bill Gates has done in selling the world on the notion of operating systems. It’s probably the greatest con game the world has ever seen.

Lisp did not address I/O. In fact, C did not address I/O and because it didn’t, it needed an operating system. Forth addressed I/O from the very beginning. I don’t believe in the most common denominator. I think that if you go to a new machine, the only reason it’s a new machine is because it’s different in some way and you want to take advantage of those differences. So, you want to be there at the input-output level so you can do that.


So, I was certainly interested in the idea of Forth running on bare-metal. What I found quickly was byok.

I was able to get it compiled fairly easily using the pre-built toolchain provided by the author. However, I had to delete two lines in the kernel directory Makefile:

diff --git a/kernel/Makefile b/kernel/Makefile
index b54cfb0..4ed0dc3 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -49,9 +49,7 @@ $(CRTN_OBJ) \
 $(CRTI_OBJ) \
 $(OBJS) \
 $(CRTN_OBJ) \
 all: byok.kernel

The system boots up using Grub. The words display as expected.

words display in BYOK

I was able to create variables and store/pull data from them. However, a slight oddity is that the @ symbol and the ” symbol are swapped around on the keyboard, which had me confused for about 10 minutes. But I was fine after figuring that out.

working with variables in BYOK

The system comes with a nice block editor, for saving a program to block memory, though I think actual disk I/O is not coded yet.

block editor in BYOK
loading code from block memory

And the dump word is available:

hex dump which appears after running v cell dump

I’m definitely interested in playing around with this some more, and exploring what x86 architecture functionality is accessible with memory reads and writes.


3 thoughts on “BYOK: Bare Metal Forth”

  1. Nothing like reinventing the wheel is there … to ignorant brains like mine interesting … but quite beyond my comprehension. Ah, I have a great friend at work who can help overcome my ignorance. Great article.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s