Getting da65 info files to behave sanely with mapper MMIO

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Getting da65 info files to behave sanely with mapper MMIO
by on (#228147)
I'm dealing with da65, because disasm6 seems to think it's smarter than it really is (not to mention can't handle CDL files that spread across multiple banks).

MMC1-based game has code like this, located in the last bank (hard-wired to $C000-FFFF):

Code:
  and #$0F                 
  sta $11                 
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  lsr A                   
  sta $FFFF               
  rts                     

How does one "sanely" deal with this in a da65 info file -- specifically the conundrum of the programmer choosing $FFFF for the MMC1 PRG bank select address, which just so happens to be the high byte of the IRQ vector? (The game has no actual IRQ usage, so the IRQ vector ($FFFE-FFFF) itself contains $FFFF as well)

If I use something like this:

Code:
range { start $c2a7; end $c318; type code; name "NMI"; };
range { start $fef4; end $ff0b; type code; name "PRG_BANK_SWAP"; };
range { start $ffd8; end $ffdf; type code; name "RESET"; };
range { start $fffa; end $ffff; type addrtable; };

I end up with this mess:

Code:
PRG_BANK_SWAP:
        and     #$0F
        sta     $11
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        lsr     a
        sta     LFFFA+5
        rts

...

LFFFA:  .addr   NMI
        .addr   RESET
        .addr   LFFFA+5

If I add:
Code:
label { addr $ffff; size 1; name "MMC1_PRG_SELECT"; };

I end up with this:
Code:
PRG_BANK_SWAP:
        and     #$0F
        sta     $11
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        lsr     a
        sta     MMC1_PRG_SELECT
        rts

...

        .addr   NMI
        .addr   RESET
MMC1_PRG_SELECT := * + 1
        .addr   MMC1_PRG_SELECT

...which makes sense of course, but is perplexing.

One cannot hand-modify the disassembly file because as one works out what's data vs. code, one needs to re-run da65 to get an updated disassembly, losing hand-hacked changes.

Along the same lines: the game reads from ROM regions that contain data/whatever, but obviously writes to those regions go to MMC1; da65 thinks they're essentially one in the same, which makes for some really nasty disassembled results.

This is all with da65 V2.17 - Git c2568d8.

Advice/thoughts?

P.S. -- Do inline comments actually work for labels? I've been futzing around with COMMENT in label and range, but I can't quite get the latter to work how I'd expect, and the former always seems to generate comments like ; thing\nlabelname := $addr rather than what one of the examples shows.

Edit -- minor copy-paste mistake on my part pertaining to the PRG swap routine. Thing has the same routine in several places...