{"id":15060279,"url":"https://github.com/andrewchambers/minias","last_synced_at":"2025-04-05T11:04:41.186Z","repository":{"id":46360742,"uuid":"412691217","full_name":"andrewchambers/minias","owner":"andrewchambers","description":"A mini x86-64 assembler for fun and learning.","archived":false,"fork":false,"pushed_at":"2025-03-15T21:36:42.000Z","size":200,"stargazers_count":212,"open_issues_count":0,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T02:52:54.502Z","etag":null,"topics":["assembler","assembly","x86-64"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewchambers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-02T04:40:19.000Z","updated_at":"2025-03-26T18:41:36.000Z","dependencies_parsed_at":"2022-07-25T00:46:11.808Z","dependency_job_id":null,"html_url":"https://github.com/andrewchambers/minias","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fminias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fminias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fminias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fminias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewchambers","download_url":"https://codeload.github.com/andrewchambers/minias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325694,"owners_count":20920714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembler","assembly","x86-64"],"created_at":"2024-09-24T22:55:47.089Z","updated_at":"2025-04-05T11:04:41.157Z","avatar_url":"https://github.com/andrewchambers.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minias\n\nA mini assembler for x86-64, written for fun and learning.\n\nMinias can assemble large amounts of real world software after they have been compiled with the [cproc C compiler](https://sr.ht/~mcf/cproc/). It can also\nassemble self hosted cproc, meaning it can indirectly assemble itself.\n\nProject Goals:\n\n- A simple, tiny, fast implementation (in that order).\n- Assemble the output of [cproc](https://sr.ht/~mcf/cproc/)/[qbe](https://c9x.me/compile/) and [chibicc](https://github.com/rui314/chibicc).\n- Relocatable elf output.\n\nNon Goals:\n\n- Assemble every assembly instruction.\n- Assemble other architectures.\n- Work as a library.\n\n# Building\n\nInstall the [peg/leg](https://www.piumarta.com/software/peg/) parser generator, make and a C compiler and run:\n\n```\nmake\n```\n\nor \n\n```\nleg asm.peg \u003e asm.peg.inc\ncc -O2 *.c -o minias\n```\n\n# Roadmap\n\nEssential features:\n\n- [x] Self host with cproc.\n- [ ] Self host with chibicc.\n\nBonus features:\n\n- [ ] A man page explaining what is supported.\n- [x] Two pass jump relaxing.\n- [x] Immediate relaxing.\n- [ ] Simple immediate expressions.\n- [ ] Assemble a libc.\n- [ ] Test every opcode with all variants in our test suite.\n- [ ] Parser that doesn't depend on peg/leg or an optimized peg that checks common prefixes.\n\n# Notes\n\n- The implementation deliberately does not free allocated memory as it all is\n  freed by the OS at the end of execution. Memory usage is still\n  quite light as it uses string and value interning. In the future\n  we could use an arena allocator for minias and still avoid manual calls to free.\n\n- The implementation deliberately uses global variables in a style similar class members in C++.\n  This is a more traditional unix style where the unit of data encapsulation is a\n  small program. This choice makes sense given we don't aim to build a library.\n\n- Minias deliberately keeps the peg grammar quite repetitive\n  and simple, please keep it this way as it is easy to understand and\n  it leaves the door open for code generation.\n\n- Performance is limited by the parser, it would be interesting\n  to see if we can improve the parser generator upstream. That being said,\n  performance is often better than gnu as and much better than the clang assembler,\n\n- One day it would be nice to write a 'minipeg' in a single .c\n  file that can be bundled in projects.\n\n# Contact\n\nAsk questions on the [mailing list](https://lists.sr.ht/~ach/minias).\nSubmit bugs to the [ticket system](https://todo.sr.ht/~ach/minias).\n\n# Resources\n\n- [intel reference](https://software.intel.com/content/dam/develop/external/us/en/documents-tps/325383-sdm-vol-2abcd.pdf) - Specifically chapter 2.1 and chapter 3.1.\n- [elf spec](https://refspecs.linuxfoundation.org/elf/elf.pdf)\n- [osdev wiki](https://wiki.osdev.org/X86-64_Instruction_Encoding)\n- [goas](https://github.com/DQNEO/goas)\n- [neatas](https://repo.or.cz/neatas.git)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewchambers%2Fminias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewchambers%2Fminias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewchambers%2Fminias/lists"}