Tiny compiler that writes raw binaries

512lang is a small, self-contained compiler that emits x86-64 machine code directly.

No LLVM, no external toolchain — C backend and Go frontend. What you write is what we encode.

No LLVM
No linker
Direct binary emission

Code Examples

Practical snippets that show the syntax and behavior of the language.

Pipeline: source → binary

How the parts fit together to produce an ELF, with zero external dependencies.

1

Go parser

Recursive‑descent parser in Go, runs basic semantic checks and types, then walks the tree to drive codegen.

Semantic checks

1.5

SWIG: Go to C wrappers

SWIG generates slim Go wrappers for the C backend so the parser calls codegen directly — no hand‑written cgo.

See "swig" folder on project repo.

2

C backend: raw x86‑64 opcodes

The C backend encodes instructions directly. No assembler, no LLVM. Operations map to byte sequences appended to a buffer.

3

ELF writer (C)

Wrap the bytes into a minimal ELF: file header, program headers. All written in C.

Result: a runnable ELF produced without an external toolchain.