Git Product home page Git Product logo

minias's Introduction

minias

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

Minias can assemble large amounts of real world software after they have been compiled with the cproc C compiler. It can also assemble self hosted cproc, meaning it can indirectly assemble itself.

Project Goals:

  • A simple, tiny, fast implementation (in that order).
  • Assemble the output of cproc/qbe and chibicc.
  • Relocatable elf output.

Non Goals:

  • Assemble every assembly instruction.
  • Assemble other architectures.
  • Work as a library.

Building

Install the peg/leg parser generator, make and a C compiler and run:

make

or

leg asm.peg > asm.peg.inc
cc -O2 *.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 that doesn't depend on peg/leg or an optimized peg that checks common prefixes.

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 peg 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,

  • One day it would be nice to write a 'minipeg' in a single .c file that can be bundled in projects.

Contact

Ask questions on the mailing list. Submit bugs to the ticket system.

Resources

minias's People

Contributors

andrewchambers avatar michaelforney avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.