// HACKER NEWS — CYBERSECURITY
Sectorforth is a 16-bit x86 Forth that fits in a 512-byte boot sector (2020)
sectorforth is a 16-bit x86 Forth that fits in a 512-byte boot sector.
Inspiration to write sectorforth came from a 1996
Usenet thread
(in particular, Bernd Paysan's first post on the thread).
sectorforth contains only the eight primitives outlined in the Usenet
post above, five variables for manipulating internal state, and two I/O
primitives.
With that minimal set of building blocks, words for branching, compiling,
manipulating the return stack, etc. can all be written in Forth itself
(check out the examples!).
The colon compiler (:) is available, so new words can be defined easily
(that means ; is also there, of course).
Contrary to many Forth implementations, sectorforth does not attempt to
convert unknown words to numbers, since numbers can be produced using the
available primitives. The two included I/O primitives are sufficient to
write a more powerful interpreter that can parse numbers.
sectorforth was developed using NASM 2.15.01. Earlier versions of NASM
are probably capable of compiling it, but that hasn't been tested.
That will produce a compiled binary (sectorforth.bin) and a floppy disk
image (sectorforth.img) containing the binary in its boot sector.
The makefile contains two targets for running sectorforth in QEMU:
Up to 4KB of input can be entered per line. After pressing return, the
interpreter parses one word at a time an interprets it (i.e. executes it
or compiles it, according to the current value of the state variable).