6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 8:01 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Jul 30, 2017 7:41 am 
Offline

Joined: Sun Mar 19, 2017 2:21 am
Posts: 25
I've been working on my processor quite a bit over the last couple days and started implementing the ASL and LSR opcodes using absolute addressing mode. I observed that for other instructions that use the ALU (e.g., ADC) that mode takes 4 clock cycles to complete. Assuming that ASL and LSR are using the ALU as well, it seems odd to me that those operations would take longer.

Is there a reason it takes an extra two clock cycles for those two instructions to execute relative to the others? Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 30, 2017 7:49 am 
Offline

Joined: Sun Mar 19, 2017 2:21 am
Posts: 25
I may have answered my own question - the block diagram for the processor shows the ALU connected to an adder for some reason. Perhaps the ALU needed to use that to add something to the shifted result and then another clock cycle to register it back in the processor?


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 30, 2017 8:21 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
I think at least part of your answer lies in the '816 data sheet:
Attachment:
AbsRMWcycles.gif
AbsRMWcycles.gif [ 16.04 KiB | Viewed 3982 times ]

Attachment:
65cycleNotes.gif
65cycleNotes.gif [ 61.61 KiB | Viewed 3982 times ]

It takes an extra cycle to do the operation and another to do the write-back since the result does not go in a processor register. Note that "data high" in the table (in the column second from the right edge) only applies to the '816 and only when you have its accumulator in 16-bit mode, and does not apply to the '02.

_________________
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: Sun Jul 30, 2017 12:43 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
gmcastil wrote:
other instructions that use the ALU (e.g., ADC) that mode takes 4 clock cycles to complete.
Right. ADC requires just a single access to memory at the specified address.

In contrast, ASL LSR ROL ROR INC and DEC are Read-Modify-Write instructions. They conclude by taking what's at the specified address, altering it, and putting it back. The "alter it and put it back" is what adds the two extra cycles. You can see this in the chart excerpt Garth posted.

(ADC operates on the Accumulator -- an internal register. The "alter it and put it back" doesn't require access to memory.)

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 31, 2017 1:50 pm 
Offline

Joined: Sun Mar 19, 2017 2:21 am
Posts: 25
Yeah, I completely missed that in the instruction description - for some reason it completely escaped me that I needed to do something with the result. I suppose that's what I deserve working on code at 3:00 AM. I need to go back and modify some of my design now.


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

All times are UTC


Who is online

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