How Programs Actually Run

Program Execution Flow.svg

<aside> <img src="/icons/info-alternate_blue.svg" alt="/icons/info-alternate_blue.svg" width="40px" />

This project implements the compiler stage of the pipeline: it translates source code into x86-64 assembly. The remaining steps – assembling, linking, and resolving external libraries – are handled by existing system tools such as NASM and ld.

</aside>

How a Compiler Works

A compiler is a program that transforms source code into assembly code through six distinct phases.

Compiler Phases.svg

The Six Phases of Compilation

When source code enters the compiler, it goes through six distinct transformation phases. Refer to the pages below to learn about each phase in depth:

1. Lexical Analysis

2. Syntax Analysis (Parsing)

3. Semantic Analysis

4. Intermediate Representation (IR)

5. Code Generation

<aside> <img src="/icons/info-alternate_blue.svg" alt="/icons/info-alternate_blue.svg" width="40px" />

I’ve excluded the optimisation phase to keep the focus on the fundamental compilation pipeline.

</aside>