As everyone knows, the 6502 has many many undefined opcodes. One of these is RRA, which essentially performs both ROR and ADC.
From what I understand of hardware (really not much) and the explanation in this document, the example program:
rra $02
should:
- read from the location $02,
- write its contents back while it does the shift and addition.
- write the rotated value, while latching the result of the addition into the accumulator
But here's the example run in Visual6502.
0 0000 67 1 0000 aa 00 00 fd nv‑BdIZc
0 0000 67 1 0000 aa 00 00 fd nv‑BdIZc
1 0001 02 1 0001 aa 00 00 fd nv‑BdIZc
1 0001 02 1 0001 aa 00 00 fd nv‑BdIZc
2 0002 20 1 0002 aa 00 00 fd nv‑BdIZc
2 0002 20 1 0002 aa 00 00 fd nv‑BdIZc
3 0002 20 0 0002 aa 00 00 fd nv‑BdIZc
3 0002 20 0 0002 aa 00 00 fd nv‑BdIZc
4 0002 20 0 0002 aa 00 00 fd nv‑BdIzc
4 0002 10 0 0002 aa 00 00 fd nv‑BdIzc
So my concern is that the accumulator did not change. Trying a few different values shows that the Carry flag changes as though a ROR happened.
I'm inclined to trust the Visual6502 implementation, but on the other hand, all the documents, software, emulators and everything that attest to the behaviour of the RRA opcode can't all be wrong, can they? So the document I linked to up there is quite C64-centric. Have I discovered that the Visual6502 reproduces a variant that is different from the NMOS thing in the C64 and NES?