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.
Left and Right Shifts and Absolute Addressing
Re: Left and Right Shifts and Absolute Addressing
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?
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Left and Right Shifts and Absolute Addressing
I think at least part of your answer lies in the '816 data sheet:
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Left and Right Shifts and Absolute Addressing
gmcastil wrote:
other instructions that use the ALU (e.g., ADC) that mode takes 4 clock cycles to complete.
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
https://laughtonelectronics.com/Arcana/ ... mmary.html
Re: Left and Right Shifts and Absolute Addressing
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.