My understanding is that the effective address (EA) low-byte will come from $00FF and the EA high-byte from $0000. All the software simulators I've tested indicate that the EA high-byte comes from $0100. Are the simulators wrong?
I looked into the WDC tech notes and the W65C02 should read from $00FF if I understand it correctly. I'll test it on my actual SBC tonight if I have time.
I checked the code to my 65c02 Simulator and I have it set to read from $0100! Oops. If the actual processor reads from $00FF, I'll update my Simulator accordingly.
I also have an older 65c02 made by VLI, I'll try it too if there's time.
Michal Kowalski's 6502 simulator gets the high byte from $0000
It looks like it does when you watch the 'Arg' field in the 'uP Registers and Stack' window. However, have a look at the value of the accumulator after the operation is performed.
As expected, my W65C02 pulled the high address byte from zero page $00, not $0100. I'll have to go and update the code on my simulator. Its a simple one-line edit, so will not be hard.
As expected, my W65C02 pulled the high address byte from zero page $00, not $0100. I'll have to go and update the code on my simulator. Its a simple one-line edit, so will not be hard.
Thanks for pointing it out!
Daryl
I seem to recall that the 65C02/65C816 programming book I have (from WDC) in storage stated that this kind of page wrap-around was a bug, and that it has been "fixed". That is to say, that reading from $00FF/$0100 is "correct."
Can anyone confirm this verbiage? Otherwise, I'll have to spend a whole day to get my book out from storage.
If Daryl's WDC 65c02 pulled the high byte from 0000 in his experiment, I'd say it wasn't changed. It is my understanding that it was an intentional part of the design to improve performance and keep the die size smaller by leaving the high address byte alone instead of looking to see if another clock would be necessary to increment it after incrementing the low byte. Since less than 0.4% of possible ZP starting locations would result in this incrementing, it makes sense.
I tested this on a GTE 65C02 and a GTE 65C816. LDA ($FF) uses $FF and $00 on the 65C02. With the memory contents:
$0000 $00
$00FF $00
$0100 $01
LDA ($FF) puts $00 in the accumulator.
When e=1 (emulation mode), LDA ($FF) uses $FF and $00, just like the 65C02. When e=0 (native mode), LDA ($FF) uses $00FF and $0100. When e=0 and m=1, with the above memory contents, LDA ($FF) puts $01 in the accumulator. When e=0 and m=0, with the following memory contents:
$0000 $00
$0001 $FF
$00FF $00
$0100 $01
$0101 $FE
LDA ($FF) puts $FE01 in the accumulator. (D, the direct register, was $0000 for these tests.)
As expected, my W65C02 pulled the high address byte from zero page $00, not $0100. I'll have to go and update the code on my simulator. Its a simple one-line edit, so will not be hard.
Thanks for pointing it out!
Daryl
I've fixed my simulator code to correctly use $0000 for the high byte in the Indirect Zero Page addressing mode. This change was made to version 2.1 and is available from my web site.