turnip

turnip is a forth operating system on top of a virtual machine

it's in its very early stages right now

inspired by projects designed for virtual machines that have remained useable for decades, seeing if i can build a cozy nest of computer beeps and boops that can be stable for years to come

vm (diatom)

the virtual machine turnip runs on is called diatom.

it runs bytecode assembled from a custom assembly language, and interacts with the host system through a few different 'ports'

diatom is a 32-bit processor and uses two 512-cell stacks

builtins

codenamestack effectdescription
0quit( err -- )quits the vm, popping error/exit code
1bell( -- )beeps!
2debug( value -- )prints stack value as hex
3memory( -- addr )pushes highest available RAM address
4clock( -- sec nsec )pushes realtime clock value
5stdin vector( addr -- )sets the stdin vector address
6stdout( char -- )prints one char to stdout
7file open( fname -- len err )opens file internally and returns length in bytes of the file, and 0 if no error
8file seek( offset -- char err )sets seek internally and returns char at that position in file; warns and returns ( -- 0 1 ) if offset exceeds length of file
9file putc( char -- err )writes char to current seek position in current open file; non-fatal error if no file open
10file ls( path addr -- err )writes newline-separated string of filenames to given addr, 0 if no error
11screen:init( width height -- )creates a screen window (detroying previous windows)
12screen:pixel( x y r g b -- )pixel! does not render yet
13screen:render( -- )renders the screen

opcodes

forth (the turnip)

a small forth core is written in diatom assembly language, and once compiled and run it interprets / compiles all further forth code.