6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Apr 18, 2024 2:07 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Dec 11, 2014 8:10 am 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 337
Hi all,

A quick question to help a friend Roland over on Stardot get his new Acorn Atom design working.

What are the occasions where a SY6502 will issue exactly two successive write cycles on the bus, as observed here:
http://www.stardot.org.uk/forums/downlo ... &mode=view

The only one I can think of is a JSR instruction pushing the program counter onto the stack, but wouldn't that have a dead cycle in between (where SP is decremented)?

IRQ and NMI would be also include the status registers.

It's possible this is a hardware bug, as the design is still being debugged.

Dave


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 8:21 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10789
Location: England
JSR was my first guess too, but in fact any RMW instruction (increment, decrement, shift, rotate) will write back the old value and then write back the modified value. See the INC instruction starting in cycle 12 at
http://www.visual6502.org/JSSim/expert. ... f&steps=40
and
http://en.wikipedia.org/wiki/MOS_Techno ... and_quirks

This applies to all the NMOS variations - the CMOS chips perform extra reads instead of extra writes.

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 8:29 am 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 337
Yes, I just spotted that one in the bug list:

http://en.wikipedia.org/wiki/MOS_Techno ... and_quirks

Quote:
The 6502's read-modify-write instructions perform one read and two write cycles. First the unmodified data that was read is written back, and then the modified data is written. This characteristic may cause issues by twice accessing hardware that acts on a write. This anomaly continued through the entire NMOS line, but was fixed in the CMOS derivatives, in which the processor will do two reads and one write cycle. Good programming practice will generally avoid this problem by not executing read/modify/write instructions on hardware registers.


Thanks,

Dave


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 9:22 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8422
Location: Southern California
Quote:
The only one I can think of is a JSR instruction pushing the program counter onto the stack, but wouldn't that have a dead cycle in between (where SP is decremented)?

No, the writes are in successive cycles, with no dead cycle in between.  In the interrupts, there are three writes in a row, two for return address and one for status.  This is covered in the 6502 interrupts primer.  This diagram is in it:
Attachment:
figure_1.gif
figure_1.gif [ 20.1 KiB | Viewed 18 times ]

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 10:29 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10789
Location: England
GARTHWILSON wrote:
Quote:
The only one I can think of is a JSR instruction pushing the program counter onto the stack, but wouldn't that have a dead cycle in between (where SP is decremented)?

No, the writes are in successive cycles, with no dead cycle in between.

Indeed, the incrementing of the stack pointer is done in parallel.
Previously:
"Q. When is the stack pointer not the stack pointer?"
A. During JSR, the SP goes off to the ALU to be incremented and the S register is used a temporary register to hold the high byte of the destination.
(Link to a visual6502 simulation)


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 7:49 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1678
Location: Sacramento, CA
Don't forget the BRK instruction as it also has three successive writes.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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: