Code generator

This is the final phase of a compiler. It takes as input the optimized intermediate representation of the source code and generate machine code for the required architecture.

Example
a = b + 60 would result in machine code that looks something like this -

MOV b, R1
MOV 60, R2
ADD R1, R2
STOR R1, a

This phase of the compiler is responsible for handling memory allocation errors, or improper allocation of registers.