Page 1 of 1

Zero page indirect addressing question

Posted: Mon Apr 04, 2005 4:38 pm
by petej
Please can you explain how the following 65C02 opcode works:

Code: Select all

LDA ($FF)
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?

Posted: Mon Apr 04, 2005 5:13 pm
by 8BIT
Pete,

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.

Daryl

Re: Zero page indirect addressing question

Posted: Mon Apr 04, 2005 6:48 pm
by leeeeee
Quote:
All the software simulators I've tested indicate that the EA high-byte comes from $0100. Are the simulators wrong?
Michal Kowalski's 6502 simulator gets the high byte from $0000

http://home.pacbell.net/michal_k/6502.html

Lee.

Re: Zero page indirect addressing question

Posted: Mon Apr 04, 2005 7:31 pm
by petej
Quote:
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.

Here's my test code:

Code: Select all

	.ORG	$00
	.DB	$20
	.ORG	$ff
	.DB	$30
	.ORG	$2030
	.DB	$05
	
	.ORG	$F000
	.START	main
main:	LDA	($FF)
	NOP
	NOP

Posted: Tue Apr 05, 2005 4:10 am
by 8BIT
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

Posted: Thu Apr 28, 2005 3:40 pm
by kc5tja
8BIT wrote:
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.

Posted: Thu Apr 28, 2005 5:20 pm
by GARTHWILSON
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.

Posted: Sat May 07, 2005 10:01 pm
by dclxvi
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.)

Posted: Tue May 31, 2005 1:15 pm
by 8BIT
8BIT wrote:
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.

Daryl

http://users.softcom.net/darylr