{"id":17703220,"url":"https://github.com/anubhav-narayan/mxsm","last_synced_at":"2026-05-02T13:31:13.753Z","repository":{"id":258596969,"uuid":"864507846","full_name":"anubhav-narayan/mxsm","owner":"anubhav-narayan","description":"MX Cross Assembler","archived":false,"fork":false,"pushed_at":"2024-10-19T16:53:46.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T08:29:35.147Z","etag":null,"topics":["assembler","assembly","custom-assembler"],"latest_commit_sha":null,"homepage":"","language":"Python","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/anubhav-narayan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-09-28T12:06:04.000Z","updated_at":"2024-11-11T05:23:17.000Z","dependencies_parsed_at":"2024-10-21T14:22:14.148Z","dependency_job_id":null,"html_url":"https://github.com/anubhav-narayan/mxsm","commit_stats":null,"previous_names":["anubhav-narayan/mxsm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhav-narayan%2Fmxsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhav-narayan%2Fmxsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhav-narayan%2Fmxsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anubhav-narayan%2Fmxsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anubhav-narayan","download_url":"https://codeload.github.com/anubhav-narayan/mxsm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413242,"owners_count":20773053,"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","custom-assembler"],"created_at":"2024-10-24T20:05:51.830Z","updated_at":"2026-05-02T13:31:13.744Z","avatar_url":"https://github.com/anubhav-narayan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MX Assembler\n\nMX Cross Assembler is a command-line tool for assembling machine code for the MX architecture (or theoratically any architecture). This tool takes an assembly source file and a production mapping file in JSON format and generates binary output files for data and instruction segments.\n\n## Features\n\n- **Source Code Parsing**: Reads and tokenizes the MX11 assembly source code(or any other, if you have the correct `prod.json.tab`).\n- **Instruction and Data Segmentation**: Separates `.data` and `.ins` directives into respective memory segments.\n- **Code Segmenetation**: Separates the code into `.ins` and `.nmi`, `.irq` sections for interrupt service routines.\n- **Symbol Resolution**: Handles labels and symbolic addresses.\n- **Binary Generation**: Outputs binary files for both data and instruction segments.\n\n## Requirements\n\n- Python 3.8+\n- `click` library for the command-line interface.\n- `json` library for parsing the production mapping.\n\n## Installation\n\n### Using Poetry\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/anubhav-narayan/mxsm.git\n    cd mxsm\n    ```\n\n2. Install the dependencies using [Poetry](https://python-poetry.org/):\n\n    ```bash\n    poetry install\n    ```\n\n3. If you want to use the CLI command globally, you can use:\n\n    ```bash\n    poetry build\n    ```\n\n## Usage\n\n### Command-Line Interface\n\n```shell\n$ mxsm --help\nUsage: mxsm [OPTIONS] [PROD_FILE] INPUT_FILE\n\n  MXSM - MX Cross Assembler\n\n  2-Pass Cross Architecture Assembler for MX Architecture\n\n  INPUT_FILE: Path to the MX assembly file.\n\n  PROD_FILE: Production table file in JSON. [default: ./prod.tab.json]\n\nOptions:\n  -o, --output PATH  Directory to save the assembled binary files.  [default:\n                     ./build]\n  --debug            Print debug information after assembly.\n  --help             Show this message and exit.\n$\n```\n\n## MX11SU `prod.json.tab`\n\n```json\n{\n  \"NMI_ADDR\": 128,\n  \"IRQ_ADDR\": 192,\n  \"INSTRUCTION_LENGTH\": 1,\n  \"DATA_LENGTH\": 1,\n  \"INS\": [\n    \"NOP\",\n    \"NOT\",\n    \"NAND\",\n    \"XOR\",\n    \"XNOR\",\n    \"AND\",\n    \"OR\",\n    \"NOR\",\n    \"ADD\",\n    \"ADC\",\n    \"SUB\",\n    \"SBB\",\n    \"INCR\",\n    \"DECR\",\n    \"X2\",\n    \"CLR\",\n    \"RST\",\n    \"MOV\",\n    \"LDI\",\n    \"LD\",\n    \"ST\",\n    \"SHM\",\n    \"SHL\",\n    \"SHR\",\n    \"ROL\",\n    \"ROR\",\n    \"JNZ\",\n    \"JZ\",\n    \"JNC\",\n    \"JC\",\n    \"JNE\",\n    \"JE\",\n    \"JGT\",\n    \"JLT\",\n    \"RJNZ\",\n    \"RJZ\",\n    \"RJNC\",\n    \"RJC\",\n    \"RJNE\",\n    \"RJE\",\n    \"RJGT\",\n    \"RJLT\",\n    \"HALT\"\n  ],\n  \"REGS\": [\n    \"A\",\n    \"X\",\n    \"Y\",\n    \"D\",\n    \"DAR\",\n    \"MBR\",\n    \"INSP\",\n    \"FLAGS\",\n    \"SA\",\n    \"SX\",\n    \"SY\",\n    \"SD\",\n    \"R0\",\n    \"R1\",\n    \"R2\",\n    \"R3\"\n  ],\n  \"PROD\" : {\n    \"INSTRUCTION\": {\n      \"idepth\": 1,\n      \"NOP\": \"00\",\n      \"NOT\": \"01\",\n      \"NAND\": \"02\",\n      \"XOR\": \"03\",\n      \"XNOR\": \"04\",\n      \"AND\": \"05\",\n      \"OR\": \"06\",\n      \"NOR\": \"07\",\n      \"ADD\": \"08\",\n      \"ADC\": \"09\",\n      \"SUB\": \"0a\",\n      \"SBB\": \"0b\",\n      \"INCR\": \"0c\",\n      \"DECR\": \"0d\",\n      \"X2\": \"0e\",\n      \"CLR\": \"0f\",\n      \"RST\": \"6f\",\n      \"SHM\": \"94\",\n      \"JNZ\": \"a0\",\n      \"JZ\": \"a1\",\n      \"JNC\": \"a2\",\n      \"JC\": \"a3\",\n      \"JNE\": \"a4\",\n      \"JE\": \"a5\",\n      \"JLT\": \"a6\",\n      \"JGT\": \"a7\",\n      \"RJNZ\": \"a8\",\n      \"RJZ\": \"a9\",\n      \"RJNC\": \"aa\",\n      \"RJC\": \"ab\",\n      \"RJNE\": \"ac\",\n      \"RJE\": \"ad\",\n      \"RJLT\": \"ae\",\n      \"RJGT\": \"af\",\n      \"INTR\": \"f2\",\n      \"HALT\": \"ff\"\n    },\n    \"INSTRUCTION,REGISTER\": {\n      \"idepth\": 2,\n      \"MOV\": {\n        \"X\": \"10\",\n        \"Y\": \"20\",\n        \"D\": \"30\"\n      },\n      \"NOT\": {\n        \"A\": \"01\",\n        \"X\": \"11\",\n        \"Y\": \"21\",\n        \"D\": \"31\"\n      },\n      \"NAND\": {\n        \"A\": \"02\",\n        \"X\": \"12\",\n        \"Y\": \"22\",\n        \"D\": \"32\"\n      },\n      \"XOR\": {\n        \"A\": \"03\",\n        \"X\": \"13\",\n        \"Y\": \"23\",\n        \"D\": \"33\"\n      },\n      \"XNOR\": {\n        \"A\": \"04\",\n        \"X\": \"14\",\n        \"Y\": \"24\",\n        \"D\": \"34\"\n      },\n      \"AND\": {\n        \"A\": \"05\",\n        \"X\": \"15\",\n        \"Y\": \"25\",\n        \"D\": \"35\"\n      },\n      \"OR\": {\n        \"A\": \"06\",\n        \"X\": \"16\",\n        \"Y\": \"26\",\n        \"D\": \"36\"\n      },\n      \"NOR\": {\n        \"A\": \"07\",\n        \"X\": \"17\",\n        \"Y\": \"27\",\n        \"D\": \"37\"\n      },\n      \"ADD\": {\n        \"A\": \"08\",\n        \"X\": \"18\",\n        \"Y\": \"28\",\n        \"D\": \"38\"\n      },\n      \"ADC\": {\n        \"A\": \"09\",\n        \"X\": \"19\",\n        \"Y\": \"29\",\n        \"D\": \"39\"\n      },\n      \"SUB\": {\n        \"A\": \"0a\",\n        \"X\": \"1a\",\n        \"Y\": \"2a\",\n        \"D\": \"3a\"\n      },\n      \"SBB\": {\n        \"A\": \"0b\",\n        \"X\": \"1b\",\n        \"Y\": \"2b\",\n        \"D\": \"3b\"\n      },\n      \"INCR\": {\n        \"A\": \"0c\",\n        \"X\": \"1c\",\n        \"Y\": \"2c\",\n        \"D\": \"3c\",\n        \"DAR\": \"4c\",\n        \"MBR\": \"5c\",\n        \"INSP\": \"6c\",\n        \"FLAGS\": \"7c\"\n      },\n      \"DECR\": {\n        \"A\": \"0d\",\n        \"X\": \"1d\",\n        \"Y\": \"2d\",\n        \"D\": \"3d\",\n        \"DAR\": \"4d\",\n        \"MBR\": \"5d\",\n        \"INSP\": \"6d\",\n        \"FLAGS\": \"7d\"\n      },\n      \"X2\": {\n        \"A\": \"0e\",\n        \"X\": \"1e\",\n        \"Y\": \"2e\",\n        \"D\": \"3e\"\n      },\n      \"CLR\": {\n        \"A\": \"0f\",\n        \"X\": \"1f\",\n        \"Y\": \"2f\",\n        \"D\": \"3f\",\n        \"DAR\": \"4f\",\n        \"MBR\": \"5f\",\n        \"INSP\": \"6f\",\n        \"FLAGS\": \"7f\"\n      },\n      \"LD\": {\n        \"A\": \"b0\",\n        \"X\": \"b1\",\n        \"Y\": \"b2\",\n        \"FLAGS\": \"b3\",\n        \"R0\": \"b4\",\n        \"R1\": \"b5\",\n        \"R2\": \"b6\",\n        \"R3\": \"b7\"\n      },\n      \"ST\": {\n        \"A\": \"b8\",\n        \"X\": \"b9\",\n        \"Y\": \"ba\",\n        \"FLAGS\": \"bb\",\n        \"R0\": \"bc\",\n        \"R1\": \"bd\",\n        \"R2\": \"be\",\n        \"R3\": \"bf\"\n      },\n      \"SHM\": {\n        \"SA\": \"90\",\n        \"SX\": \"91\",\n        \"SY\": \"92\",\n        \"SD\": \"93\",\n        \"A\": \"94\",\n        \"X\": \"95\",\n        \"Y\": \"96\",\n        \"D\": \"97\"\n      }\n    },\n    \"INSTRUCTION,NUMBER\": {\n      \"idepth\": 2,\n      \"LDI\": {\n        \"0\": \"e0\",\n        \"1\": \"e1\",\n        \"2\": \"e2\",\n        \"3\": \"e3\",\n        \"4\": \"e4\",\n        \"5\": \"e5\",\n        \"6\": \"e6\",\n        \"7\": \"e7\",\n        \"8\": \"e8\",\n        \"9\": \"e9\",\n        \"10\": \"ea\",\n        \"11\": \"eb\",\n        \"12\": \"ec\",\n        \"13\": \"ed\",\n        \"14\": \"ee\",\n        \"15\": \"ef\"\n      },\n      \"SHL\": {\n        \"0\": \"c0\",\n        \"1\": \"c1\",\n        \"2\": \"c2\",\n        \"3\": \"c3\",\n        \"4\": \"c4\",\n        \"5\": \"c5\",\n        \"6\": \"c6\",\n        \"7\": \"c7\"\n      },\n      \"ROL\": {\n        \"0\": \"c8\",\n        \"1\": \"c9\",\n        \"2\": \"ca\",\n        \"3\": \"cb\",\n        \"4\": \"cc\",\n        \"5\": \"cd\",\n        \"6\": \"ce\",\n        \"7\": \"cf\"\n      },\n      \"SHR\": {\n        \"0\": \"d0\",\n        \"1\": \"d1\",\n        \"2\": \"d2\",\n        \"3\": \"d3\",\n        \"4\": \"d4\",\n        \"5\": \"d5\",\n        \"6\": \"d6\",\n        \"7\": \"d7\"\n      },\n      \"ROR\": {\n        \"0\": \"d8\",\n        \"1\": \"d9\",\n        \"2\": \"da\",\n        \"3\": \"db\",\n        \"4\": \"dc\",\n        \"5\": \"dd\",\n        \"6\": \"de\",\n        \"7\": \"df\"\n      }\n    },\n    \"INSTRUCTION,REGISTER,REGISTER\": {\n      \"idepth\": 3,\n      \"MOV\": {\n        \"A\": {\n          \"A\": \"00\",\n          \"X\": \"10\",\n          \"Y\": \"20\",\n          \"D\": \"30\",\n          \"R0\": \"88\"\n        },\n        \"D\": {\n          \"A\": \"40\",\n          \"X\": \"50\",\n          \"Y\": \"60\",\n          \"MBR\": \"70\",\n          \"R3\": \"8b\"\n        },\n        \"X\": {\n          \"A\": \"80\",\n          \"Y\": \"84\",\n          \"D\": \"86\",\n          \"R1\": \"89\"\n        },\n        \"Y\": {\n          \"A\": \"81\",\n          \"Y\": \"85\",\n          \"D\": \"87\",\n          \"R2\": \"8a\"\n        }\n      },\n      \"NOT\": {\n        \"A\": {\n          \"A\": \"01\",\n          \"X\": \"11\",\n          \"Y\": \"21\",\n          \"D\": \"31\"\n        },\n        \"D\": {\n          \"A\": \"41\",\n          \"X\": \"51\",\n          \"Y\": \"61\",\n          \"D\": \"71\"\n        }\n      },\n      \"NAND\": {\n        \"D\": {\n          \"A\": \"42\",\n          \"X\": \"52\",\n          \"Y\": \"62\",\n          \"D\": \"72\"\n        }\n      },\n      \"XOR\": {\n        \"D\": {\n          \"A\": \"43\",\n          \"X\": \"53\",\n          \"Y\": \"63\",\n          \"D\": \"73\"\n        }\n      },\n      \"XNOR\": {\n        \"D\": {\n          \"A\": \"44\",\n          \"X\": \"54\",\n          \"Y\": \"64\",\n          \"D\": \"74\"\n        }\n      },\n      \"AND\": {\n        \"D\": {\n          \"A\": \"45\",\n          \"X\": \"55\",\n          \"Y\": \"65\",\n          \"D\": \"75\"\n        }\n      },\n      \"OR\": {\n        \"D\": {\n          \"A\": \"46\",\n          \"X\": \"56\",\n          \"Y\": \"66\",\n          \"D\": \"76\"\n        }\n      },\n      \"NOR\": {\n        \"D\": {\n          \"A\": \"47\",\n          \"X\": \"57\",\n          \"Y\": \"67\",\n          \"D\": \"77\"\n        }\n      },\n      \"ADD\": {\n        \"D\": {\n          \"A\": \"48\",\n          \"X\": \"58\",\n          \"Y\": \"68\",\n          \"D\": \"78\"\n        }\n      }\n    }\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanubhav-narayan%2Fmxsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanubhav-narayan%2Fmxsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanubhav-narayan%2Fmxsm/lists"}