14

Native Code Generation

This chapter shows you how to take the intermediate code from Chapter 9, Intermediate Code Generation, and generate native code. The term native refers to whatever instruction set is provided by hardware on a given machine. This chapter presents a simple native code generator for x64, a dominant architecture on laptops and desktops.

This chapter covers the following main topics:

  • Deciding whether to generate native code
  • Introducing the x64 instruction set
  • Using registers
  • Converting intermediate code to x64 code
  • Generating x64 output

The skills developed here include basic register allocation, instruction selection, writing assembler files, and invoking the assembler and linker to produce a native executable. The functionality ...

Get Build Your Own Programming Language - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.