pydisass6502
pydisass6502 copied to clipboard
various improvements
-
bugfix for the opcode listed as
"9d,"which was failing to generate data refs (side note: i wonder if the lists of opcodes should be maintained via tags in the opcodes.json file, and extracted from there?) -
adds a
--startaddresscommandline and entrypoints.json option as an alternative to assuming the first two bytes of the file give the offset. I'm using atari rom images which specify the offset in a different way. -
adds a
--hexdumpoption (default true) which adds a comment to each line with the PC address and either the raw bytes (for code) or ascii (for data blocks) -
adds a
--countfileoption to dump stats on usage for internal and external entrypoints, using the same json format as the entrypoint file to make it easy to iteratively label symbols and paste them into your mapping -
improves code-walking by maintaining a list of code entrypoints to process (defaulting to the start address), and making sure we visit them all. the current sequential walkthru has problems if your initial entrypoint is near the end and jumps to earlier code, since we flag one instruction as code but then don't get a chance to update the flags for later instructions in that sequence
-
improved labeling and support for user-provided symbols in entrypoints.json and mapping.json. This assigns a symbolic label like
__AC__for each "section" (each absolute code or data reference, or user-supplied entrypoint), with sublabels like_AC_1for relative branch destinations within each section. imho it makes disassembled code much easier to read -
simplified program generation, by explicitly consuming a line at a time including data blocks, rather than maintaining a bunch of extra state
-
adds an atari system mapping file, adds symbols to the c64 mapping
-
adds an example based on the blog post, which disassembles like this (I guess C64 uses non-ascii char encoding?)
; converted with pydisass6502 by awsm of mayday!
* = $0810
START lda #$00 ; 0810 a900
sta BRDCLR ; 0812 8d20d0 border color
ldy #$0b ; 0815 a00b
_START_1 lda __A__,y ; 0817 b92308
sta SCREEN,y ; 081a 990004 start of screen memory
dey ; 081d 88
bpl _START_1 ; 081e 10f7
jmp __B__ ; 0820 4c2f08
__A__ !byte $08,$05,$0c,$0c,$0f,$20,$17,$0f,$12,$0c,$04,$21 ; 0823 ..... .....!
__B__ lda BRDCLR ; 082f ad20d0 border color
sta BGCLR ; 0832 8d21d0 background color
rts ; 0835 60
Thumbs up for submitting a PR, greatly appreciated. I won't have enough time to check the code for a couple of weeks sadly, so please be patient with me, it might take a bit longer to review and especially test all the changes. Cheers!
No worries, i'll prob have a little more to add over the next couple of days. I've been comparing the Atari cartridge rom version of 'Eastern Front 1941' vs the APX diskette version (which has public source code 🙏 ) and your disassembler has been super valuable. I needed to make some initial changes since the rom has the entry point near the end, a different start-offset mechanism, and starts with a data block, and have been making various other improvements to help with readability and my detective work. Hopefully these changes will be useful to others also.