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