Code:
.org $8000
.enum $80
ZPVal .byte 0
.ende
.enum $800
NonZPVal .byte 0
.ende
lda (ZPV),y ; *********
lda (NZPV),y ; **********
.enum $80
ZPVal .byte 0
.ende
.enum $800
NonZPVal .byte 0
.ende
lda (ZPV),y ; *********
lda (NZPV),y ; **********
I am trying to decide how to handle disambiguation in my assembler. Specifically, above is the case of what to do when I encounter what appears to be an intended "post-indexed indirect" LDA on the lines marked with asterisks [intent discerned by presence of ()'s]. Obviously anyone can look at the second one and call me an idiot, because there's no way the programmer could have MEANT to try to use a non-zeropage address in an indexed indirect addressing mode. Furthermore a programmer should be well-within rights to put as many parenthesis as his paranoid mind requires, without having it cause a headache.
However, from the point-of-view of the assembler the instruction addressing mode of the marked lines is not determinable. I decided to run a test with ASM6. Sure enough, the program above assembles without error. It turns out ASM6 has decided for me that I really meant absolute indexed-by-y addressing mode for the second LDA, not post-indexed indirect as I may [or may not...I may just be a paranoid parenthesizer] have actually intended. Conversely I may have intended for absolute indexed-by-y addressing mode in the first LDA, but I get post-indexed indirect emitted without as much as a whif of confusion.
I bring this up because I want to make sure I am sane [not with regard to parenthesis emittance]. I am thinking that I will emit a "warning" that such promotions/demotions [I refer to zp-to-non-zp addressing mode shifts like this as demotions, non-zp-to-zp shifts as promotions] are occurring. Then let the user figure out whether or not this is an error in their code [ie. the value NZPV really SHOULD be a zeropage value] or just an assembler being as helpful as possible. In the case where the programmer intent is for absolute indexed-by-y addressing mode and the removal of the ()'s is not possible, perhaps a warning-supression flag or directive of some kind would be useful too.
I know there's at least one assembler out there that forces []'s upon the programmer to disambiguate this situation, but I would hate to go there.
Loopy?