{"id":24740584,"url":"https://github.com/mariosieg/machinekit","last_synced_at":"2026-05-02T05:32:18.173Z","repository":{"id":161602739,"uuid":"598721705","full_name":"MarioSieg/MachineKit","owner":"MarioSieg","description":"[WIP] single C header x86-64 code generator \u003c 300 lines","archived":false,"fork":false,"pushed_at":"2023-02-07T17:24:46.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T19:23:01.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarioSieg.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-07T17:21:40.000Z","updated_at":"2023-02-07T17:23:20.000Z","dependencies_parsed_at":"2023-06-30T13:15:27.484Z","dependency_job_id":null,"html_url":"https://github.com/MarioSieg/MachineKit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MarioSieg/MachineKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FMachineKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FMachineKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FMachineKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FMachineKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarioSieg","download_url":"https://codeload.github.com/MarioSieg/MachineKit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FMachineKit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260294085,"owners_count":22987596,"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":[],"created_at":"2025-01-27T23:24:37.452Z","updated_at":"2026-05-02T05:32:18.123Z","avatar_url":"https://github.com/MarioSieg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MachineKit [WIP]\n\u003ch3\u003e\n\n* Encode x86-64 machine language at runtime.\n* Single header x86-64 code generator in under 300 lines of C99!\n* Includes most common x86-64 instructions aswell as SSE and SSE2.\n* AVX support is planned.\n\n\u003c/h3\u003e\n\n\u003ch2\u003eSSE instruction encoding example\u003c/h2\u003e\n\n\u003ch3\u003e1. Encode some instructions from C\u003c/h3\u003e\n\n```c\n#include \"X86_64.h\"\n\nint main() {\n    X64MScar buf[8192];                 // create a buffer on the stack\n    memset(buf, XI_INT3, sizeof(buf));  // fill the buffer with the INT3 (breakpoint) instruction\n    X64MScar *p = buf;                  // create pointer as needle\n\n    // encode some SSE register-to-register instructions\n    X64_sse_rr(\u0026p, XO_ADDPS,  RID_XMM8,  RID_XMM7);\n    X64_sse_rr(\u0026p, XO_SUBSS,  RID_XMM15, RID_XMM7);\n    X64_sse_rr(\u0026p, XO_MOVSS,  RID_XMM1,  RID_XMM7);\n    X64_sse_rr(\u0026p, XO_SUBSD,  RID_XMM8,  RID_XMM11);\n    X64_sse_rr(\u0026p, XO_MOVAPS, RID_XMM8,  RID_XMM7);\n    X64_sse_rr(\u0026p, XO_MOVUPD, RID_XMM15, RID_XMM7);\n    X64_sse_rr(\u0026p, XO_DIVPS,  RID_XMM1,  RID_XMM7);\n    X64_sse_rr(\u0026p, XO_MINPD,  RID_XMM8,  RID_XMM11);\n\n    X64_machine_buf_dump_c(buf, p);   // dump the machine code in our buffer into a C like string literal\n\n    return 0;\n}\n```\n\n\u003ch3\u003e2. Machine code is generated\u003c/h3\u003e\n\u003ch4\u003eAnd can be then executed (requires mmap etc..) or printed as C string literal (X64_machine_buf_dump_c)\u003c/h4\u003e\n\n```c\nconst char *machine_code = { /* N = 35 */\n  \"\\x44\\x0f\\x58\\xc7\\xf3\\x44\\x0f\\x5c\"\n  \"\\xff\\xf3\\x0f\\x10\\xcf\\xf2\\x45\\x0f\"\n  \"\\x5c\\xc3\\x44\\x0f\\x28\\xc7\\x66\\x44\"\n  \"\\x0f\\x10\\xff\\x0f\\x5e\\xcf\\x66\\x45\"\n  \"\\x0f\\x5d\\xc3\"\n};\n```\n\u003ch3\u003e Disassembled machine code \u003c/h3\u003e\n\u003ch4\u003e Note: The operands are reversed because of AT\u0026T syntax. \u003c/h4\u003e\n\n```asm\n    Address        | Machine Language |     Assembly\n------------------------------------------------------------\n0x0000000000000000:  44 0F 58 C7       addps  %xmm7, %xmm8 \n0x0000000000000004:  F3 44 0F 5C FF    subss  %xmm7, %xmm15\n0x0000000000000009:  F3 0F 10 CF       movss  %xmm7, %xmm1 \n0x000000000000000d:  F2 45 0F 5C C3    subsd  %xmm11, %xmm8 \n0x0000000000000012:  44 0F 28 C7       movaps %xmm7, %xmm8 \n0x0000000000000016:  66 44 0F 10 FF    movupd %xmm7, %xmm15\n0x000000000000001b:  0F 5E CF          divps  %xmm7, %xmm1 \n0x000000000000001e:  66 45 0F 5D C3    minpd  %xmm11, %xmm8 \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariosieg%2Fmachinekit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariosieg%2Fmachinekit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariosieg%2Fmachinekit/lists"}