3 ms·
It's not that hard to write a "real language" compiler in assembler, lots of people have done so. Amiga-E is a good example for which source code is available.
by vidarh 11y ago
It's not that hard to write a "real language" compiler in assembler, lots of people have done so. Amiga-E is a good example for which source code is available.
A simple, Wirth-type compiler is very straight-forward to write for most simple ALGOL-family languages.
By Wirth-type compiler, I mean recursive descent parser with direct code generation (no AST). Single pass if the language allows it.
You need a handful of utility functions for lexical analysis/tokenization, symbol table management, and for outputting code, and then most of the rest is calling subroutines and simple control flow.
In fact, some parts, like code generation, can be made very simple in assembler, because you can directly inline code fragments and in effect use them as "templates".
- nickpsecurity 11y agoI'll be darned: your example [1] is indeed a real langauge written in M68K assembly. Also one I'd never heard of so thanks. Old guard's tenacity to get stuff done with constrained hardware and software continues to impress me. Regarding compiler, yeah I was thinking of the complexity of one with AST and optimizations because who would use it without that? That would be an impressive compiler in assembler. Amiga-E is impressive enough, for now, while also proving the concept. Good points as well on how an assembler style could easily use templates and such during code gen phase. I think the analysis and transform phases might be the hardest in an optimizing compiler. Just a guess, though. [1] https://en.wikipedia.org/wiki/Amiga_E https://en.wikipedia.org/wiki/Amiga_E