logoalt Hacker News

vidarh • today at 2:47 PM • 0 replies • view on HN

My first compiler was for a Pascal-like language that started with just reading assembler in and spitting assembler out, and then I layered in blocks and expressions step by step and slowly rewrite the compiler itself from a basic text processor in assembler to a proper compiler, making use of each new feature as soon as I'd made sure it worked.

I wish I still had the code for it - because it had a very simple Wirth-style code generator it was predictable enough that you could even use registers directly in expressions. (M68k, so e.g. you could do "x = D7.w" to set the variable x equal to the low 16 bit word of register D7)

EDIT: Worth mentioning Randall Hyde's "High Level Assembly"[1] here as an actually published language that did something similar.

[1] https://en.wikipedia.org/wiki/High_Level_Assembly