6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 5:19 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Apr 04, 2005 4:38 pm 
Offline

Joined: Mon Oct 18, 2004 12:18 pm
Posts: 7
Please can you explain how the following 65C02 opcode works:

Code:
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 04, 2005 5:13 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 04, 2005 6:48 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 04, 2005 7:31 pm 
Offline

Joined: Mon Oct 18, 2004 12:18 pm
Posts: 7
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:
   .ORG   $00
   .DB   $20
   .ORG   $ff
   .DB   $30
   .ORG   $2030
   .DB   $05
   
   .ORG   $F000
   .START   main
main:   LDA   ($FF)
   NOP
   NOP


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 05, 2005 4:10 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Apr 28, 2005 3:40 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Apr 28, 2005 5:20 pm 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat May 07, 2005 10:01 pm 
Offline
User avatar

Joined: Thu Mar 11, 2004 7:42 am
Posts: 362
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.)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 31, 2005 1:15 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: BigEd and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: