So RE: my original post about starting with Basic compilers on the TRS-80. I got a TRS-80 Model 4 emulator (trs80gp) running on my M1 Mac and up pops the splash screen of TRSDOS 6 ā well, hello old friend.
At any rate for fun I downloaded the entire output of Misosys (Roy Soltoffās old company ā the author of LS-DOS which was licensed on the Model 4 as TRS-DOS) including its basic compiler, EnhComp. I had forgotten just how crude things of necessity were in 8-bit land, but the minimalist environment is a fun challenge all its own:
Variable names can be any length but only upper case letters, digits, and @, plus the usual typing suffixes (%,!,#,$).
In general, apart from leading spaces on a line, no spaces allowed by the syntax.
Four data types: integer, single & double precision float, and string
You can declare functions, but only parameters are pushed onto the stack; there are no local variables as such. You either have to send extra dummy args into a function or use a naming convention to try to use working variables in global scope within the function body, treating them as pseudo-static variables. The docs donāt even contemplate this, they just assume the then-current mindset that all variables are global and it is the parameters being local (the word ālocalā isnāt even a word yet apparently) that is unusual / revolutionary.
Functions cannot have zero parameters (?!) and parameters cannot be arrays or even array elements. You can recurse up to the limits of stack space but without local variables you are effectively limited to rather simple recursion calls that only work with passed args.
When called, functions must be prefixed with !, which makes for interesting syntax if itās a function that returns a single, for which ! is the variable suffix, hence, say:
SOMEVAR! = !MYFUNC!(0)
All this shouting ā Iām not used to it anymore. Feel like writing a preprocessor just so I can write with a sane syntax and camel-casing.
No classes / objects, of course.
On the plus side:
Line numbers are entirely optional and you can completely dispense with them, using COMMAND/ENDCOM, FUNCTION/ENDFUNC and text labels instead.
Strings can be up to 32K, and given you have < 40K of free memory in practice at runtime unless you resort to bank switching, thatās plenty generous.
The compiler is also an assembler so you can drop in to Z-80 assembly language anytime you wish, with all registers saved & available.
Thereās a clever enhanced āfieldingā mechanism for fixed-width random access files.
Very nice sort functions including something roughly equivalent to Xojoās Sort ⦠With
The compiler understands includes
Also I had forgotten how terse everything is, including the documentation. The docs for the compiler, included line editor and supervisor program are excellent by the standards of the day but both the compiler design and the docs assume you have already internalized interpreted disk Basic, which I have long since forgotten most of, and thereās no concept of āsee also related commandsā, etc. I understand building on disk Basic not only for compatibility reasons but for the ability to call into the same system routines for parsing and so forth and thus save a little memory but boy I have gotten soft over the past 40 or so years!