4 ms·
I wrote a Basic interpreter once (for Infocom's Z-machine). Holy cow, that's an ugly language to parse. It's all ad-hoc rules and heuristics and endless weird e
by david-given 10y ago
I wrote a Basic interpreter once (for Infocom's Z-machine). Holy cow, that's an ugly language to parse. It's all ad-hoc rules and heuristics and endless weird edge cases. It just wasn't fun.
Forth's a good choice, and will teach you lots of assembly, but it's not really a compiler, and Z80 Forth's been done to death.
But... and I should point out that where I am it's half past midnight and I'm going weird and random... if you want an off-the-wall but useful language to do an actual compiler for, you might want to check out B. It's like a typeless simplified C (although it's really the other way round), and is eminently suited to tiny architectures.
Tiny example:
http://www.99-bottles-of-beer.net/language-b-1247.html http://www.99-bottles-of-beer.net/language-b-1247.html
x86 B compiler written in C, containing links to the language reference:
https://github.com/aap/abc https://github.com/aap/abc
- qwertyuiop924 10y ago>Forth's a good choice, and will teach you lots of assembly, but it's not really a compiler, and Z80 Forth's been done to death. The Z80 itself's been done to death. If I wanted to go super far off the beaten path, I'd build a 6809 computer (something I actually do want to do, but it's hard to get 6809s). But this is good, because I can base it largely on other's designs, which helps me get to the software bit faster (which is the part that actually excites me), although I will have to make some modifications. This is also good because I suck at electronics. Hopefully, I may suck a bit less by the time this project is done, but that's not the point, really. But yes, a B compiler might be fun. I'm sure I can at least take it as far as assembler. Mind, it will probably suck, but I'm fairly confident I can make it work. Provided, of course, that I put in the effort, which isn't a given: a lot of what I set out to do doesn't happen, because I got distracted by something else. The comparison to Leonard of Quirm is obvious, but unfair: he's a genius, and fictional: I'm real, and no genius, just easily distractable.
- david-given 10y agoYes, fair enough; you should do what you want to do, not what I say you should do. But I like compilers, so... (And the B compiler is beautifully simple and is probably really easy to port.) Re Forth, you might be interested in this: http://fruttenboel.verhoeven272.nl/Langs/ace.html http://fruttenboel.verhoeven272.nl/Langs/ace.html It's an annotated disassembly of the Jupiter Ace ROM; the Ace was a ZX80-like Z80 machine which was unique among the 8-bit computers in that it had Forth in ROM rather than Basic. It's a beautiful implementation, and includes everything from keyboard mapping to the character generator to an interactive Forth sort-of-IDE. Also, there's no modern 6809 variant? There ain't no justice.
- qwertyuiop924 10y agoThanks for the tip on that! As for the 6809, it was out of production for a while. But allegedly, Rochester Electronics is making new ones now. They even seem to have them, if you look on their site. However, they won't sell them to you.
- zincsandwich 10y agoYou can get used pulls from Jameco, Unicorn Electronics or eBay. AFTER you finish your z80 thing, of course.
- zincsandwich 10y agoOh, and the RS08 and 68HCxx are the modern 6809 offshoots, and they're still in production, but they're not quite the same as the 6809, and the 68HCxx's days may be numbered.
- qwertyuiop924 10y agoOh. Thanks. But neither of them really scratch the 6809 itch: They're closer to the 6800 and the 6502, whereas the 6809 was closer to m68k.