I'm currently implementing the last few illegals in my emulator, already passing the functional 6502 suite and NESTest. But I'm having a problem with ANC ($0B/$02), ALR ($4B) and ARR ($6B).
ANC is described in multiple references (http://www.oxyron.de/html/opcodes02.html, http://www.ataripreservation.org/websit ... lopc31.txt) to set the SR based on (A & Immediate). In my tests with Visual 6502 I find it does not do that. It seems to completely ignore the immediate value and just set the flags based on A. Same for ALR - I perfectly match Visual 6502 as soon as I remove the & and just ignore the immediate operand. Exact same story for ARR.
Looking at other emulators (i.e. http://sourceforge.net/p/vice-emu/code/ ... re.c#l2075) it's pretty clear they actually do the and. I don't see how this could work, assuming Visual 6502 to be the ground truth here.
Now if we assume that ANC sets the SR flags based on (A & Immediate), shouldn't the following code produce
LDA #$FF
ANC #$00
a set zero flag, and no negative/carry? But it doesn't. It just sets the flags based on $FF, not doing the &. I have a dozen or so test cases for ANC, ALR and ARR, and they all show that in Visual 6502 the immediate value is completely ignored and no & is performed.
Another example:
SEC
LDA #$AA
ARR #$55
After the & we should have a value of 0, and the ROR with set carry should give $80. But it doesn't. There's no & being done, the Immediate operand completely ignored and ROR is done on $AA, giving $D5.
So what's the deal here? Is every emulator and opcode reference I looked at wrong, Visual 6502 not correct, or, more likely, I'm just completely missing something here?
Thanks!
ANC is described in multiple references (http://www.oxyron.de/html/opcodes02.html, http://www.ataripreservation.org/websit ... lopc31.txt) to set the SR based on (A & Immediate). In my tests with Visual 6502 I find it does not do that. It seems to completely ignore the immediate value and just set the flags based on A. Same for ALR - I perfectly match Visual 6502 as soon as I remove the & and just ignore the immediate operand. Exact same story for ARR.
Looking at other emulators (i.e. http://sourceforge.net/p/vice-emu/code/ ... re.c#l2075) it's pretty clear they actually do the and. I don't see how this could work, assuming Visual 6502 to be the ground truth here.
Now if we assume that ANC sets the SR flags based on (A & Immediate), shouldn't the following code produce
LDA #$FF
ANC #$00
a set zero flag, and no negative/carry? But it doesn't. It just sets the flags based on $FF, not doing the &. I have a dozen or so test cases for ANC, ALR and ARR, and they all show that in Visual 6502 the immediate value is completely ignored and no & is performed.
Another example:
SEC
LDA #$AA
ARR #$55
After the & we should have a value of 0, and the ROR with set carry should give $80. But it doesn't. There's no & being done, the Immediate operand completely ignored and ROR is done on $AA, giving $D5.
So what's the deal here? Is every emulator and opcode reference I looked at wrong, Visual 6502 not correct, or, more likely, I'm just completely missing something here?
Thanks!