{"id":30776115,"url":"https://github.com/netesy/assembler","last_synced_at":"2026-04-17T06:33:23.769Z","repository":{"id":310881614,"uuid":"933045006","full_name":"netesy/assembler","owner":"netesy","description":"Simple Assembler For the Luminar Langauage","archived":false,"fork":false,"pushed_at":"2025-09-17T15:56:15.000Z","size":1122,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T18:02:24.552Z","etag":null,"topics":["assembler","backend","compiler"],"latest_commit_sha":null,"homepage":"","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/netesy.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-15T02:42:51.000Z","updated_at":"2025-08-21T19:22:07.000Z","dependencies_parsed_at":"2025-08-20T20:52:25.228Z","dependency_job_id":"bce8dd26-850a-4966-a2fb-4ef060440db2","html_url":"https://github.com/netesy/assembler","commit_stats":null,"previous_names":["netesy/assembler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/netesy/assembler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netesy%2Fassembler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netesy%2Fassembler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netesy%2Fassembler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netesy%2Fassembler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netesy","download_url":"https://codeload.github.com/netesy/assembler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netesy%2Fassembler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31918561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","backend","compiler"],"created_at":"2025-09-05T04:11:24.012Z","updated_at":"2026-04-17T06:33:23.758Z","avatar_url":"https://github.com/netesy.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# x86-64 Assembler and Executable Generator\n\n## Description\n\nThis project is a functional, albeit simplified, toolchain for assembling and linking x86-64 assembly code into a runnable 64-bit executable for both **Linux (ELF)** and **Windows (PE)**. It was developed by incrementally refactoring a non-functional assembler into a working tool.\n\nThe core components are:\n- **A two-pass Assembler:** Parses a subset of x86-64 assembly syntax and generates the corresponding machine code. It can translate Linux syscalls to Windows API calls when targeting the PE format.\n- **ELF and PE Generators:** Takes the machine code and symbol information from the assembler and packages it into a valid, static executable for the target platform.\n\n## Features\n\n- **Architecture:** x86-64 (64-bit)\n- **Output Formats:**\n    - Static ELF executable for Linux\n    - Static PE executable for Windows\n    - Relocatable object files (`.o`)\n- **Assembly Process:** Two-pass assembly to correctly handle forward-referenced labels.\n- **Addressing Modes:**\n    - Register-to-register (`mov rax, rbx`)\n    - Immediate-to-register (`mov rax, 123`)\n    - RIP-relative memory addressing (`mov rax, [my_variable]`)\n- **Control Flow:**\n    - Unconditional jumps (`jmp`)\n    - Conditional jumps (`je`, `jne`, `jl`, `jle`, `jg`, `jge`, `jz`, `jnz`)\n    - Function calls (`call`, `ret`)\n- **Stack Operations:** `push` and `pop` for 64-bit registers.\n- **Atomic Operations:** `lock` prefix supported for valid read-modify-write instructions.\n\n## Supported Instructions\n\nThe assembler currently supports the following x86-64 instructions:\n\n- **Data Transfer:** `mov`\n- **Arithmetic:** `add`, `sub`\n- **Comparison:** `cmp`\n- **Stack:** `push`, `pop`\n- **Control Flow:** `jmp`, `call`, `ret`\n- **Conditional Jumps:** `je`, `jne`, `jz`, `jnz`, `jl`, `jle`, `jg`, `jge`\n- **System Calls:** `syscall` (translated to Windows API calls for PE format)\n\n## Usage\n\n1.  **Build the Assembler:**\n    -   On Linux: `./build.sh`\n    -   On Windows: `build.bat` or `build_cmake.bat`\n\n2.  **To Generate Executables (Default):**\n    By default, the assembler generates executables for both ELF and PE formats.\n    ```sh\n    # On Linux\n    ./build/assembler \u003cinput_file.asm\u003e -o \u003coutput_file\u003e\n    # On Windows\n    build\\assembler.exe \u003cinput_file.asm\u003e -o \u003coutput_file\u003e\n    ```\n    This will create `\u003coutput_file\u003e.elf` and `\u003coutput_file\u003e.exe`.\n\n3.  **To Generate a Specific Format:**\n    Use the `--format` flag to specify either `elf` or `pe`.\n    ```sh\n    # Generate only an ELF file\n    ./build/assembler \u003cinput_file.asm\u003e -o \u003coutput_file\u003e --format elf\n\n    # Generate only a PE file\n    ./build/assembler \u003cinput_file.asm\u003e -o \u003coutput_file\u003e --format pe\n    ```\n\n4.  **To Generate a Relocatable Object File:**\n    Use the `-c` flag to generate a standard object file. The output format depends on the `--format` flag.\n\n    -   **For ELF (Linux):**\n        ```sh\n        ./build/assembler -c --format elf \u003cinput_file.asm\u003e -o \u003coutput_file.o\u003e\n        ```\n\n    -   **For COFF (Windows):**\n        ```sh\n        ./build/assembler -c --format pe \u003cinput_file.asm\u003e -o \u003coutput_file.obj\u003e\n        ```\n\n5.  **Linking with GCC:**\n    You can link the generated object file with other object files or libraries using a standard linker like GCC.\n\n    -   **For ELF (Linux):**\n        ```sh\n        gcc -no-pie -nostdlib \u003coutput_file.o\u003e -o \u003cfinal_executable\u003e\n        ```\n\n    -   **For COFF (Windows, using MinGW):**\n        ```sh\n        x86_64-w64-mingw32-gcc \u003coutput_file.obj\u003e -o \u003cfinal_executable.exe\u003e\n        ```\n\n## Sample Assembly Program\n\nThe following sample program is included in `test.asm`. It performs simple arithmetic and uses the result as the program's exit code.\n\n```asm\nsection .text\n  global _start\n\n_start:\n  mov rax, 10      ; Start with 10\n  mov rbx, 5       ; Load 5 into another register\n  add rax, rbx     ; Add them, rax = 15\n  add rax, 7       ; Add an immediate value, rax = 22\n  mov rdi, rax     ; Move the result to rdi for the exit code\n  mov rax, 60      ; syscall number for exit\n  syscall\n```\nWhen targeting Windows, the assembler will automatically translate the `syscall` instruction into a call to the `ExitProcess` function from `kernel32.dll`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetesy%2Fassembler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetesy%2Fassembler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetesy%2Fassembler/lists"}