Some initial testing sans the Macro and ensuring bad alignment.
First, some background on the source code. There are only TWO segments in the code that actually write to the Command register (address is shared with the Status register). One is an abort command, which is only found once in the code, which is:
Code:
lda wdforceirq
sta wdcmd ; send command
jsr delay40 ; wait 40uS
jsr delay40 ; wait 40uS
jsr delay40 ; wait 40uS
jmp wdunbusy
Note that the Macro is not used here, so apparently the terminate command to the FDC is not a sensitive one for the address, or perhaps the fact that there is just a group of delays following the terminate command. The second place in the code that the Command register is written to is where ALL FDC commands are handled as:
Code:
wdbusy
WDTEST
sta wdcmd ; send command
lda #bit0
WDTEST
1? bit wdstat
beq 1?
jmp delay16
The Macro is used above for both sending a command to the FDC and again for testing the busy bit in the Status register. Another commonly used code piece is here:
Code:
wdunbusy
lda #bit0
WDTEST
1? bit wdstat
bne 1?
rts
As in the previous code segment, the Macro is used to ensure the address alignment. So my first test was to disable the Macro in these two code segments and add NOPs to ensure a bad alignment of the instructions, i.e., the lower two bits are zero for each access to the Command and Status register. This required 6 NOPs added and the Macro commented out. I burned another EPROM, put it into the drive and.... it works fine, or at least appears to. I assembled my old C64 DOS front end (uses dozens of files) and it completed without an issue. I also deleted some files, recreated them, did a CHKDSK command, etc. and it functions normally.
So, my initial take away on the this is the instructions used to test the Status register. In the cases above, the BIT instruction is used, not the LDA instruction. It would appear that using the BIT instruction doesn't cause an error, or, as Jeff mentioned earlier, perhaps it's the post alignment that doesn't cause a problem. I don't feel I'm any closer to figuring this out, but perhaps the Commodore team didn't fully understand the problem either (based on the above findings).
All other accesses of the Status register are done by using LDA WDSTAT and all of these appear to require the address alignment. The majority of these code segments are identical:
Code:
main7 ldx #12
WDTEST ; chk address
cmd70 lda wdstat
and #3
lsr a
bcc v1
beq cmd70
lda #0
sta wddat
dex
bne cmd70
The above snippet from the format track code. So perhaps it's something specific to the differences between the BIT and LDA instructions or the following instructions after the LDA.