xorvoid/sectorc logo

xorvoid/sectorc

Free

A C Compiler that fits in the 512 byte boot sector of an x86 machine

FreeFree tier
Type
Open Source

About xorvoid/sectorc

SectorC is a C compiler written in x86-16 assembly that fits entirely within the 512-byte boot sector of an x86 machine, making it arguably the smallest C compiler ever created. Despite its tiny size, it supports a surprisingly capable subset of C including global variables, functions, if/while statements, operators, pointer dereference, inline machine-code, and comments. It can compile real programs such as a moving sine-wave animation, a text greeting, and a PC speaker melody. The project includes a formal grammar, example code, and is released as open source on GitHub.

Key Features

Fits entirely within 512 bytes of x86 boot sector
Written in x86-16 assembly
Supports global variables, functions, if/while statements, operators, pointer dereference, inline machine-code, and comments
Includes example programs: sine-wave animation, hello world, PC speaker tune
Formal grammar provided
Open source on GitHub

Pros & Cons

Pros
  • Extremely small footprint (512 bytes) enables self-contained boot sector programs
  • Written in pure assembly, showcasing low-level compiler design
  • Supports a non-trivial subset of C, allowing real programs
  • Includes inline assembly for direct hardware access
  • Free and open source
Cons
  • Only targets x86-16 real mode, not portable
  • Very limited C subset (no structs, floats, arrays? Actually arrays are not mentioned? The grammar shows only int type. No arrays explicitly? Actually variables are int. So no arrays, no function return values except void? Functions are void. So very limited.)
  • No standard library support
  • Primarily a novelty/educational tool, not suitable for production software

Best For

Boot sector programming and experimentationEducational demonstration of compiler construction in constrained environmentsRetro computing and x86 real-mode software developmentEmbedded systems with x86-16 architecture

FAQ

How small is SectorC?
The entire compiler fits within 512 bytes, the size of an x86 boot sector.
What subset of C does SectorC support?
It supports global int variables, void functions, if/while statements, arithmetic and logical operators, pointer dereference, inline machine-code via 'asm' keyword, and comments.
Can SectorC run real programs?
Yes, example programs include a moving sine-wave animation, a text display, and a PC speaker melody.
Is SectorC open source?
Yes, the source code is available on GitHub under the repository xorvoid/sectorc.