An Operating System for the TTA16
It sounds big but really its just a "shell".
Forth
I first looked at Forth. I wrote a Forth interpreter in the early nineties (based on eForth I think) and compiled to 3.8kb (DOS com file) for the core (1974 lines). The forth library was a further 11.4kb (426 lines).
I wrote a second version for the 8031/51 CPU as I had an emulator to test the code. The 8031/51 is more primative than the 8086 so would make a better starting point. But still the assembler source code is 1735 lines long, so not small.
I found the beautified Buzzard Forth code (by Sean Barrett) which is very minimum bootstrap forth with its library. Its about 160 lines (excluding comments) and the library is about 6.6k (367 lines). No point taking about the gcc compiled file at 93.3kb!
Mouse
I came across Peter Grogono's mouse-79. A very small language, about 200 lines of pascal or C code. It superficially looks like Forth as a uses RPN logic, but it does not have a work dictionary and words cannot be defined. It uses subroutines (macros) that have local variables (i.e it is recursive).
O/S Purpose
The shell need not be a full language like Forth but something more like a unix shell. So if I strip out the macros, the shell has many language like features but no subroutines. Here is an example of "100 beer bottles on the wall":
X 100 =
(
X. ! " Bottle(s) of beer on the wall,!"
X. ! " bottle(s) of beer!"
"Take one down and pass it around,!"
X 1 X . - =
X. ! " bottle(s) of beer on the wall.!"
X . ^
)
$$
And here is the mouse language without macros:
- $$ end of program
- " print up to next "
- ! print CR/LF inside "'s
- ? read number from stdin and push
- ! pop number from stack and print it
- n push the integer n onto stack
- A-Z push address of variable on stack
- . replace address on stack with value
- = pop value, pop address, write value at address
- + pop a, pop b, push a + b
- - pop a, pop b, push a - b
- * pop a, pop b, push a * b
- / pop a, pop b, push a / b
- [ pop c, if c<=0 then skip to ] on same level
- ) loop back to previous ( at same level
- ^ pop c, if c!=0 then break out of loop
The code is still being reduced to suit its new application.
AlanX
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.