Сообщение от Paul Reed
7. Writing a New Code Generator
The general method which we found extremely helpful when developing a new code generator is the same as that explained in Project Oberon [1]. Before describing his compiler in detail, Wirth first lists fifteen sample 'code patterns' (we added a sixteenth for our open-array operations), showing what machine code should be output for a particular set of sample Oberon statements and expressions.
These patterns are far from working programs, but as Wirth points out, the discipline of deciding which code should be output (usually with a paper and pencil in our case) is a prerequisite, before discovering how best to design the generator. Working our way through the patterns kept the complexity of the task in check.
Each code-generation procedure has a standardised interface, and there are 14 procedures in all:
Released () Move () Addr() Index () MonOpO BinOpO Branch () JumpO Trap () Case () PrepCallO Call() Enter () Return ()