minias

June 24, 2026 ยท View on GitHub

A mini assembler for x86-64, written for fun and learning.

Minias can assemble large amounts of real world software after it has been compiled to assembly by compilers including GCC, Clang, cproc/qbe, and chibicc. It can also assemble itself (After compilation with a C compiler).

Project Goals:

  • A simple, tiny, fast implementation (in that order).
  • Assemble the output of GCC, Clang, cproc/qbe, and chibicc.
  • Support a reasonable practical set of AT&T x86-64 assembly.
  • Relocatable elf output.

Non Goals:

  • Match every GNU assembler extension.
  • Assemble other architectures.
  • Work as a library.

Building

Install make and a C compiler and run:

make

The build uses the vendored Minipeg parser generator from the Minipeg git repository in vendor/minipeg.

or

cc -O2 -o vendor/minipeg/minipeg vendor/minipeg/minipeg.c
vendor/minipeg/minipeg -o asm_parser.c asm.peg
cc -O2 main.c parse.c util.c -o minias

Roadmap

Essential features:

  • Self host with cproc.
  • Self host with chibicc.

Bonus features:

  • A man page explaining what is supported.
  • Two pass jump relaxing.
  • Immediate relaxing.
  • Simple immediate expressions.
  • Assemble a libc.
  • Test every opcode with all variants in our test suite.
  • Parser generated by vendored Minipeg.

Notes

  • The implementation deliberately does not free allocated memory as it all is freed by the OS at the end of execution. Memory usage is still quite light as it uses string and value interning. In the future we could use an arena allocator for minias and still avoid manual calls to free.

  • The implementation deliberately uses global variables in a style similar class members in C++. This is a more traditional unix style where the unit of data encapsulation is a small program. This choice makes sense given we don't aim to build a library.

  • Minias deliberately keeps the Minipeg grammar quite repetitive and simple, please keep it this way as it is easy to understand and it leaves the door open for code generation.

  • Performance is limited by the parser, it would be interesting to see if we can improve the parser generator upstream. That being said, performance is often better than gnu as and much better than the clang assembler.

Resources