Okay. Where do I start ?
This time round I decided to write a new language of some sort for the Commander CX-16. This, for those of you who don't know is a Retrocomputer designed by (among others) David "8 Bit Guy" Murray, and it's basically a souped up modernised C64. So it sort of counts as Retro (it's still got a 6502 in it) even though it's only a few months old.
I didn't want to duplicate anyone else's work or ideas. I wanted something that would be self hosting (if a compiler) and the option of writing the Compiler in 6502 assembler or bootstrapping it.
So I looked at various options for ideas, or even something worth copying
Pascal - there's a Tiny Pascal in Byte which I thought I could adapt and extend
Quick - Quick is an Atari High Level Assembler - part way between a HLL and Assembler.
65CM,C65CM, Pas64 - more High Level Assemblers, variations on the same theme.
Action, PL/65, Promal - various specific 6502 languages that resemble C type languages
Color FORTH - there are already several people wanting to do this, this is a bit different.
Stage 2 - some work by Professor Waite on Macro generation languages.
The 6502 has a lot of faults. Sometimes I wonder what's good about it other than it (was) cheap. The thing is, it really doesn't do these things that well. Especially when it's running the BASIC ROM from the C64 which grabs half of zero page. Some of my experiments ended up with a lot of lda xxx adc xxx sta xxxx all over the place, often with word addresses. I looked at some quite serious compiler projects and they tended to have the same problems.
I did look at byte compilers, there's quite a nifty one for the Vic20, but it's just too limited. That was where Color Forth came from, one way to avoid the load and save locals problem is not to have any., or not many. I looked at porting my Flat-Forth I created for the Z80, and never quite finished, but that didn't really work either.
Some work round it with Runtime systems, but then you lose quite a lot of the clout. Some have serious optimisers, which isn't ever going to fit on a 6502 machine really.
So I ended up with two options. One was Color FORTH. The other was a language as unnamed, called CX16-HLA. This is quite advanced (in the sense that the bootstrap generates code and it runs and I wrote some functions), and it sort of works round the load add save by having an 16 bit or 8 bit accumulator modelled around YA, and doing operations in 8 bit or 16 bit mode.
So it looked a bit like count + 1 - 4 ^ $4C => result type code with loops, ifs and procedures. Definitely better, but still not happy with it.
I very nearly did that - there's a working compiler, and there's a semi working Color FORTH as well. I might finish them later.
So, basically, I nearly abandoned it. Then in an odd musing about another system pretty much nobody remembers from the 80s and browsing about it, I came across something else, that gave me an idea.
No comments:
Post a Comment