Summary
This chapter showed you how to generate bytecode for software bytecode interpreters. The skills you learned include how to traverse a linked list of intermediate code and, for each intermediate code opcode and pseudo-instruction, how to convert it into instructions in a bytecode instruction set. There were big differences between the semantics of the three-address machine and the bytecode machine. Many intermediate code instructions were converted into three or more bytecode machine instructions. The handling of CALL
instructions was a bit hairy, but it is important for you to perform function calls in the manner required by the underlying machine. While learning all this, you also learned how to write out bytecode in text and binary formats.
The next chapter presents an alternative that is more attractive for some languages: generating native code for a mainstream CPU.