Disassembler for 6502 processors.
- Simple command-line interface
- Single file, ANSI C source
- Annotation for IO addresses of Nintendo Entertainment System (NES) system registers
- Apple 2 / Atari style output via
-a
- Cycle-counting output via
-c
- Machine code display inline with the disassembly via
-d
- Skip 'n' beginnign bytes of binary via
-b #
- Assembly style output via
-s
NES output: dcc6502 -b 4 -d -o 0x900 -m 10 hgrbyte.bin
; Source generated by DCC6502 version v2.4
; For more info about DCC6502, see https://github.com/Michaelangel007/dcc6502
; FILENAME: hgrbyte.bin, File Size: $023B (571)
; -> Hex output enabled
;---------------------------------------------------------------------------
ORG $0900 ;
$0900> A9 10: LDA #$10 ;
$0902> 2C 54C0: BIT $C054 ;
$0905> 2C 50C0: BIT $C050 ;
$0908> 2C 5300: BIT $0053 ;
Apple 2 output: dcc6502 -b 4 -d -o 0x900 -m 10 -a hgrbyte.bin
; Source generated by DCC6502 version v2.4
; For more info about DCC6502, see https://github.com/Michaelangel007/dcc6502
; FILENAME: hgrbyte.bin, File Size: $023B (571)
; -> Hex output enabled
; -> Apple II output enabled
;---------------------------------------------------------------------------
ORG $0900 ;
0900:A9 10 LDA #$10 ;
0902:2C 54 C0 BIT $C054 ;
0905:2C 50 C0 BIT $C050 ;
0908:2C 53 00 BIT $0053 ;
Compile via the de-facto make:
make clean && make all
The included makefile has a bunch of options:
Option | Effect |
---|---|
clean | Delete binary files |
all | Build code and binary test files |
help | Show makefile help options |
illegal | Build and test illegal 6502 opcodes |
install | Build and copy to /opt/local/bin/disasm6502 |
zero | Build and test zero-length file |
NOTE: The binary is installed into /opt/local/bin/
as disasm6502
in order not to over-write any previous versions of dcc6502
.
-
Cycle Timing
- http://nesdev.com/6502_cpu.txt
- https://github.com/ramiropolla/mame-ap2k/tree/master/src/emu/cpu/m6502
Dcc6502 has the following cycle timing bugs that have been fixed in this fork:
Instruction | Opcode | Bad | Fixed |
---|---|---|---|
ROL abs,X | 3E | 7 | 6 |
LSR abs,X | 5E | 7 | 6 |
ROR abs,X | 7E | 7 | 6 |
STA (zp),Y | 91 | 5 | 6 |
STA abs,Y | 99 | 4 | 5 |
STA abs,X | 9D | 4 | 5 |
- Instruction decoding changed from naive linear O(151) to fast O(1)
- Fixed off-by-one file length bug
- Files no longer disassemble one past their length
- Zero length files now work properly
- Fixed slow reading file one byte at a time to a single, fast, read
- Fixed buffer overflow memory access
- Miscellanous code cleanup to make it easy to read
The original 1.0 version of dcc6502 was written overnight on Christmas eve 1998. At the time, I (Tennessee Carmel-Veilleux) was a 16-year-old NES hacker learning 6502 assembly. Of course, as many teenagers are, I was a bit arrogant and really thought my code was pretty hot back then :) Fast-forward 15 years and I'm a grown-up engineer who is quite a bit more humble about his code. Looking back, I think the tool did the job, but obviously, 15 years of experience later, I would have made it quite a bit cleaner. The disassembler has floated online on miscalleanous NES development sites since 1998. I decided to put it on github starting at version 1.4 and I will be cleaning-up the code over until version 2.0.
This disassembler has made the rounds and has been used for a lot of different purposes by many different people over the years. Hopefully it will continue to be useful going forward.
In 2017 AppleWin debugger developer Michael was looking for a simple disassembler for future "Apple Games Disassembly Projects." After seeing that the foundation was "good enough" he got involved fixing the poor performance, design, user experience, and miscellaneous bugs. A testament to the good C foundation -- not the typical bloatd C++ crap that is over-engineered that passes for these days.