Comment by FarmerPotato

Comment by FarmerPotato 5 days ago

5 replies

Write an operating system in Forth.

I've digested Wirth's THE paper. And the XINU book, as well as the BSD book.

Anyhow it's for my own use on my own hardware, but it must be beautiful. I've been encouraged by feedback on my Forth code's clear Forthiness, in the way of small, comprehendable word units. That add up to poetic top level loops like OVER PROCESS OVER SCHEDULE IDLE

elcapitan 5 days ago

That sounds like fun! Which is THE paper by Niklas Wirth?

  • incognito124 5 days ago

    Likely Project Oberon

    • FarmerPotato 4 days ago

      You're not wrong... but I was mixed up:

      Edsgar Dijkstra, The THE multiprogramming system (1968)

      Niklaus Wirth, Project Oberon

araes 5 days ago

That's a very specific skill development. I'd ask why Forth, yet guess because "must be beautiful"?

Seems like kind of strange / yet somewhat appropriate choice since Forth "traditionally use neither operating system nor file system." and "A full-featured Forth system with all source code will compile itself". Bootstrap your own operating system on a computer with literally nothing.

Interesting to read about though as a tangent, very different kind of language. "grammar has no official specification" "looks the word up in the dictionary" and then does whatever the dictionary specifies.

Good luck on the project though, seems like it fell out of use in the 80's and only got recovered recently. The Forth Interest Group comments on the subject are funny too. [1] "What ANS Forths are available?" -> "The simple answer is: none" Apparently somebody (Vincent Hamp) got it to work on Thumb-2 ISA (ARMv7-M and newer) though. Tiny. 7kb flash, 320B of ram. [2]

[1] https://www.forth.org/ansforth/ansforth.html

[2] https://gitlab.com/higaski/Shi

  • FarmerPotato 4 days ago

    The primary virtue of a Forth system is that it is interactive. You can see this on any 1990s system that can start up in Open Firmware.

    I've started with a FIG-Forth kernel in 9900 assembler, which fits into 8K. Many authors worked that code up to the 1990s branch I grabbed.

    To bring up the board, I cross-assemble to produce two Flash EEPROMs, plug them in, and power up. The Forth kernel looks at block 6 for customizations where I tell it to compile some source packages I want from Flash. One of these is -ASSEMBLER, which lets me create short chunks of native machine code to work on very low-level things like bit I/O, the SPI and I2C peripheral behavior. Very good for debugging initial hardware.

    When I'm happy with some code, I add the source to the next EEPROM build.

    Block numbers were originally 1K chunks of disk, but can refer to any kind of storage like pages of ROM/RAM, or even to a process' virtual address space.