C64 Project: BASIC Disassembler
2026-11-17 04:19 pmA disassembler is useful when you don't have the original assembly source. A machine language program simply looks like a stream of bytes. It will be unintelligible unless you are really, really good at matching numbers to opcodes. That may happen to you. Eventually.... $60? That's RTS. $A9 $00? That's LDA #$00.
So what does it do? It attempts to convert bytes into mnemonics/arguments (i.e., assembly). That is how $60 becomes RTS and $A9 $00 becomes LDA #$00. Is the conversion perfect? Yes. And. No. First, labels cannot be recovered, thus, address style arguments are always absolute, zeropage, or relative values. If immediate arguments employed labels they too are obliterated. Second, data mixed with code converts to gibberish. Otherwise, the conversion is exact.
I created this disassembler to assist my workflow. I need to revise all of my conditional branching instructions to shift from labels to offsets (i.e., from BEQ QUIT to BEQ *+9, where the +9 is relative to the BEQ's memory location). It is a bottleneck.... Could it be done by hand? Sure. If I had to do it by hand, though, there would be hundreds upon hundreds of mistakes. I designed this disassembler to calculate the offset automatically for me.
Alright, so what does this look like?
( ... lots and lots of documentation follows ... )
And ... that's all she wrote.
So for my next time-waster, I'm going to make a version of this that disassembles machine language already resident in RAM. I'll follow that by a resident machine language program that prints a fancy 'disassembler' style listing of BASIC programs. When I'm done with all of that nonsense, I'll resume my two big projects: revising my assembler code to take advantage of the * update and continue to code my grade ledger app for the C64. Adios!
So what does it do? It attempts to convert bytes into mnemonics/arguments (i.e., assembly). That is how $60 becomes RTS and $A9 $00 becomes LDA #$00. Is the conversion perfect? Yes. And. No. First, labels cannot be recovered, thus, address style arguments are always absolute, zeropage, or relative values. If immediate arguments employed labels they too are obliterated. Second, data mixed with code converts to gibberish. Otherwise, the conversion is exact.
I created this disassembler to assist my workflow. I need to revise all of my conditional branching instructions to shift from labels to offsets (i.e., from BEQ QUIT to BEQ *+9, where the +9 is relative to the BEQ's memory location). It is a bottleneck.... Could it be done by hand? Sure. If I had to do it by hand, though, there would be hundreds upon hundreds of mistakes. I designed this disassembler to calculate the offset automatically for me.
Alright, so what does this look like?
( ... lots and lots of documentation follows ... )
And ... that's all she wrote.
So for my next time-waster, I'm going to make a version of this that disassembles machine language already resident in RAM. I'll follow that by a resident machine language program that prints a fancy 'disassembler' style listing of BASIC programs. When I'm done with all of that nonsense, I'll resume my two big projects: revising my assembler code to take advantage of the * update and continue to code my grade ledger app for the C64. Adios!






