Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong timing with LSR abs,X / ROR abs,X / ROL abs,X for the 6502 CPU #801

Closed
Archange427 opened this issue Jun 18, 2020 · 5 comments
Closed
Labels
Milestone

Comments

@Archange427
Copy link

According to Lichty's book, 6502 datasheet and various other documents, these 3 opcodes :
LSR abs,X
ROR abs,X
ROL abs,X
(hex values: $5E / $3E / $7E)
have a duration of 7 cycles (in all cases) with 6502 and not 6.
6+ cycles are only for 65C02

Strangely ASL abs,X is OK.

@tomcw
Copy link
Contributor

tomcw commented Jun 18, 2020

Thanks - I'll take a look.
It's easy to test with a Mockingboard's 6522.

Cross-referencing with Sather UTAIIe (or UTAII), page 4-24, Table 4.2 "6502 Instructions":

  • ASL, LSR, ROL, ROR: for 'ABS X' => type 23 & 24
  • Type 23 = ASL abs,x (NO PX) = 7 cycles
  • Type 24 = ASL abs,x (PX) = 7 cycles

Cross-referencing with Sather UTAIIe, page 4-27, Table 4.3 "65C02 Instructions":

  • ASL, LSR, ROL, ROR, DEC, INC: for 'ABS X' => type 23 & 24
  • Type 23 = ASL abs,x (NO PX) = 6 cycles
  • Type 24 = ASL abs,x (PX) = 7 cycles

@tomcw
Copy link
Contributor

tomcw commented Jun 18, 2020

NB. AppleWin's 65C02 DEC/INC abs,x are the same for NO-PX or PX, so this needs fixing for the NO-PX case.

EDIT: No! As Nick says in #271:

INC abs,X and DEC abs,X were not optimized on the 65C02 - always 7 cycles.

@tomcw
Copy link
Contributor

tomcw commented Jun 18, 2020

Also compare to #271, where you raised a similar issue, and I applied some fixes - but maybe not 100% correct!

@tomcw
Copy link
Contributor

tomcw commented Jun 19, 2020

Tested on real h/w, unenhanced NMOS 6502:

300: A2 00 AD 04 C4 1E FF 20 AE 04 C4 00

.ORG $300
 LDX #0
 LDA $C404
 ASL $20FF,X
 LDX $C404
 BRK
insn opcode No PX PX
asl abs,x 1E 7 7
rol abs,x 3E 7 7
lsr abs,x 5E 7 7
ror abs,x 7E 7 7

@tomcw tomcw closed this as completed in 42d265a Jun 19, 2020
@tomcw tomcw added the bug label Jun 19, 2020
@tomcw tomcw added this to the 1.29.14 milestone Jun 19, 2020
@tomcw
Copy link
Contributor

tomcw commented Aug 18, 2020

@Archange427 - FYI, fixed in AppleWin 1.29.14.0 here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants