{"id":13846355,"url":"https://github.com/notfoundry/ppasm","last_synced_at":"2025-07-12T07:32:29.718Z","repository":{"id":53799573,"uuid":"242997383","full_name":"notfoundry/ppasm","owner":"notfoundry","description":"x86_64 macro assembler entirely in C preprocessor","archived":false,"fork":false,"pushed_at":"2020-03-01T23:39:20.000Z","size":32,"stargazers_count":37,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-02-17T10:36:34.817Z","etag":null,"topics":["assembler","metaprogramming","preprocessor","x86"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notfoundry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-25T12:43:59.000Z","updated_at":"2023-12-26T09:14:15.000Z","dependencies_parsed_at":"2022-08-23T04:51:02.384Z","dependency_job_id":null,"html_url":"https://github.com/notfoundry/ppasm","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/notfoundry%2Fppasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notfoundry%2Fppasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notfoundry%2Fppasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notfoundry%2Fppasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notfoundry","download_url":"https://codeload.github.com/notfoundry/ppasm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225807256,"owners_count":17527220,"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","metaprogramming","preprocessor","x86"],"created_at":"2024-08-04T18:00:30.910Z","updated_at":"2024-11-21T21:30:25.035Z","avatar_url":"https://github.com/notfoundry.png","language":"C","readme":"# ppasm\nAre you tired of executing your C compiler on your source code to get your binaries? With `ppasm`'s **fully-preprocessor x86_64 assembler**, you can skip the compiler and move straight to the action!\n\nLet's take a look at some of `ppasm`'s killer features:\n\n| ppasm | literally any C compiler |\n|--|--|\n| 4 phases of compilation, super speedy! | 8 phases of compilation, slow and boring... |\n| No types at all, maximum productivity! | Static type system, kills prototyping speed... |\n| Full-blown functional language for macros! | Crappy old macro system, a complete pain... |\n| Unlimited flexibility, anything is possible! | Restricted semantics, C standard controls you... |\n\n## Table of Contents\n- [Overview](#overview)\n- [Tutorial](#tutorial)\n\n## Overview\nTODO: Comparison with NASM syntax\n\n## Tutorial\nLet's take a simple example of a factorial. As a C program, this might look like:\n```c\nunsigned int fac(unsigned int n) {\n\tunsigned int acc = n;\n\twhile (--n) acc *= n;\n\treturn acc;\n}\n```\nand in NASM assembly, this might be represented as:\n```nasm\nfac:\n\tmov eax, edi\n\tmov edx, edi\n\tsub edx, 1\n\tje .end\nloop:\n\timul eax, edx\n\tsub edx, 1\n\tjne .loop\n\tret\nend:\n\tmov eax, 1\n\tret\n```\nBut compiling that would take significant effort! One would have to invoke the entire C compiler (a heavyweight tool!) to produce a binary from the first snippet, and one would need to get a third-party assembler to do anything useful with the second. Not so with `ppasm`:\n```c\n#include \u003cppasm/ppasm.h\u003e\n\nassemble (\n\tmov (eax, edi),\n\tmov (edx, edi),\n\tsub (edx, 1),\n\tje (8R),\n\n\tlabel (8L, imul (eax, edx)),\n\tsub (edx, 1),\n\tjne (8L),\n\n\tlabel (8R, mov (eax, 1)),\n\tret\n)\n```\nBy simply running this through your C preprocessor, the program will be compiled into a string containing the raw-escaped bytes of the assembled instructions! To get the final binary file, all one needs to do is run `printf \"%b\"` on the output and redirect the resulting binary stream into your file of choice!\n","funding_links":[],"categories":["Compilers/Interpreters"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotfoundry%2Fppasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotfoundry%2Fppasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotfoundry%2Fppasm/lists"}