A mini assembler for x86-64, written for fun and learning.
Minias can assemble itself and many/most things compiled with the cproc C compiler i.e., large amounts of real world software.
- A simple, tiny, fast implementation (in that order).
- Assemble the output of cproc/qbe and chibicc.
- Relocatable elf output.
- Assemble every assembly instruction.
- Assemble other architectures.
- Work as a library.
Install the peg/leg parser generator, make and a C compiler and run:
leg asm.peg > asm.peg.inc cc -O2 *.c -o minias
- Self host with cproc.
- Self host with chibicc.
- Two pass jump relaxing.
- Immediate relaxing.
- Simple immediate expressions.
- Assemble a libc.
- Test every opcode with all variants in our test suite.
- Parser that doesn't depend on peg/leg.
Minias 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.
Minias deliberately keeps the peg grammar quite repetitive and simple, please keep it this way.
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,
One day it would be nice to write a 'minipeg' in a single .c file that can be bundled in projects.