{"id":26052526,"url":"https://github.com/qalle2/nes-disasm","last_synced_at":"2025-04-10T23:25:15.035Z","repository":{"id":171908769,"uuid":"303784267","full_name":"qalle2/nes-disasm","owner":"qalle2","description":"an NES (6502) disassembler","archived":false,"fork":false,"pushed_at":"2024-12-18T22:22:05.000Z","size":302,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T20:12:35.749Z","etag":null,"topics":["6502","asm6","assembly","command-line","disassembler","nes","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qalle2.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":"2020-10-13T17:44:00.000Z","updated_at":"2024-12-18T22:22:08.000Z","dependencies_parsed_at":"2024-11-26T08:21:39.941Z","dependency_job_id":"f216d60c-718b-445e-a25c-9191d3a8080b","html_url":"https://github.com/qalle2/nes-disasm","commit_stats":null,"previous_names":["qalle2/nes-disasm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qalle2%2Fnes-disasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qalle2%2Fnes-disasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qalle2%2Fnes-disasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qalle2%2Fnes-disasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qalle2","download_url":"https://codeload.github.com/qalle2/nes-disasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313661,"owners_count":21082895,"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":["6502","asm6","assembly","command-line","disassembler","nes","python3"],"created_at":"2025-03-08T06:40:51.269Z","updated_at":"2025-04-10T23:25:15.009Z","avatar_url":"https://github.com/qalle2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nes-disasm\nAn NES (6502) disassembler. The output is compatible with [ASM6](https://www.romhacking.net/utilities/674). There's an example of the output in `sample-output.txt`.\n\nTable of contents:\n* [Command line arguments](#command-line-arguments)\n* [Labels](#labels)\n* [CDL files](#cdl-files)\n* [Macros](#macros)\n* [Limitations](#limitations)\n* [Hints](#hints)\n* [To do](#to-do)\n\n## Command line arguments\nSyntax: *options* *inputFile*\n\n### Options\n* `-h` or `--help`: print a short summary of this help.\n* `-c FILE` or `--cdl-file FILE`: The FCEUX code/data log file (`.cdl`) to read. (If you don't specify one, all PRG ROM bytes will be considered unaccessed.)\n* `-i INTEGER` or `--indentation INTEGER`: How many spaces to use for indentation (1 to 100, default=16).\n* `-d INTEGER` or `--data-bytes-per-line INTEGER`: How many data bytes to print per `hex ...` line (1 to 100, default=8).\n* `-a RANGES` or `--no-access RANGES`: Assume the game never reads, writes or executes addresses within these ranges, inclusive\n(using any instruction with absolute addressing, or indexed absolute with these addresses as the base address).\n  * `RANGES` is zero or more ranges separated by commas.\n  * A range is two 16-bit hexadecimal addresses separated by a hyphen.\n  * E.g. `0800-1fff,2008-3fff,4020-5fff,6000-7fff` = mirrors of RAM, mirrors of PPU registers, beginning of cartridge space, PRG RAM.\n* `-w RANGES` or `--no-write RANGES`: Assume the game never writes addresses within these ranges, inclusive\n(using STA, STX, STY, DEC, INC, ASL, LSR, ROL or ROR with absolute addressing, or indexed absolute with these addresses as the base address).\n  * `RANGES` is zero or more ranges separated by commas.\n  * A range is two 16-bit hexadecimal addresses separated by a hyphen.\n  * E.g. `8000-ffff` = PRG ROM.\n* `--no-anonymous-labels`: Always output named labels instead of anonymous labels (`+` and `-`).\n* `-l` or `--list-opcodes`: Just list supported opcodes and exit. Note: you still need to specify a fake input file (see positional arguments below); it doesn't need to exist.\n\n### Positional arguments\n* *inputFile*: The raw PRG ROM file to read.\n  * Size: 1 byte to 32 KiB.\n  * The file is assumed to be at the end of the 6502 memory space. That is, the origin address is always 64 KiB minus the file size.\n  * Note: iNES ROM files (`.nes`) are not supported; to convert one into a raw PRG ROM data file, use `ines_split.py` from [my NES utilities](https://github.com/qalle2/nes-util).\n\n## Labels\nThe disassembler automatically assigns labels to addresses:\n* RAM (including mirrors, i.e. `$0000-$1fff`):\n  * `arr1`, `arr2`, \u0026hellip;: arrays, i.e., accessed at least once using direct indexed addressing, i.e., zeroPage,x / zeroPage,y / absolute,x / absolute,y.\n  * `ram1`, `ram2`, \u0026hellip;: never accessed using direct indexed addressing.\n* `$2000-$7fff`:\n  * `ppu_ctrl`, `ppu_mask`, \u0026hellip;: NES memory-mapped registers.\n  * `misc1`, `misc2`, \u0026hellip;: other addresses.\n* PRG ROM (`$8000-$ffff`):\n  * `sub1`, `sub2`, \u0026hellip;: subroutines (accessed at least once using the JSR instruction).\n  * `cod1`, `cod2`, \u0026hellip;: other code (never accessed with JSR, but accessed at least once with JMP absolute or a branch instruction).\n  * `+`, `-`: anonymous code labels (only accessed with nearby JMP absolute or branch instructions, with no other labels in between; use `--no-anonymous-labels` to disable).\n  * `dat1`, `dat2`, \u0026hellip;: data (never accessed with JSR, JMP absolute or a branch instruction).\n\n## CDL files\nThe disassembler has a limited support for log files created with FCEUX Code/Data Logger (`.cdl`). If a CDL file is used, PRG ROM bytes are treated as follows according to their corresponding CDL bytes:\n* CDL byte `0bxxxxxxx1` (code or both code and data): attempt to disassemble.\n* CDL byte `0bxxxxxx10` (data only): output as data (`hex ...`).\n* CDL byte `0b00000000` (unaccessed): attempt to disassemble, or if `--unaccessed-as-data` is used, output as data; in either case, add `(unaccessed)` to the comment.\n\n## Macros\nIf the file to be disassembled unnecessarily uses 16-bit addressing (absolute/absolute,x/absolute,y) with addresses less than or equal to `$ff`,\nthe disassembler will replace that instruction with a macro like `lda_abs`.\nOtherwise ASM6 would optimize the instruction to use zero page addressing instead, and the reassembled binary would not be identical to the original.\n\n## Limitations\n* Undocumented 6502 opcodes are not supported.\n* Directly vs. indirectly accessed code and data are not distinguished when parsing CDL files.\n\n## Hints\n* Using a CDL file and the `-a` and `-w` options makes the output a lot clearer.\n(They help the disassembler avoid disassembling bytes that make no sense as code.)\n* Use my [cdl-summary](https://github.com/qalle2/cdl-summary) to extract more info from CDL files.\n\n## To do\n* automatically print CLC followed by ADC as a macro; same for SEC and SBC\n* allow more anonymous labels (e.g. allow an anonymous forward jump to cross an anonymous backward jump and vice versa)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqalle2%2Fnes-disasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqalle2%2Fnes-disasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqalle2%2Fnes-disasm/lists"}