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

CPU::executeBranch may calculate wrong m_skipCycles #35

Open
Froser opened this issue Sep 13, 2022 · 1 comment
Open

CPU::executeBranch may calculate wrong m_skipCycles #35

Froser opened this issue Sep 13, 2022 · 1 comment

Comments

@Froser
Copy link

Froser commented Sep 13, 2022

According to Opcode matrix from http://www.oxyron.de/html/opcodes02.html:

"*" : add 1 cycle if page boundary is crossed.
add 1 cycle on branches if taken.

From cpu.cpp line 349:
if (branch) { int8_t offset = m_bus.read(r_PC++); ++m_skipCycles; auto newPC = static_cast<Address>(r_PC + offset); setPageCrossed(r_PC, newPC, 2); r_PC = newPC; }

If the branch is taken, and page is crossed, m_skipCycles will increase by 3. But according to the document, only 2 cycles should be added.
Is there any mistake, or did I misunderstand the document?
Thank you.

@amhndu
Copy link
Owner

amhndu commented Sep 13, 2022

Hi!
I was mostly following this IIRC. There it says:

2 (+1 if branch succeeds
+2 if to a new page)

I think I may have misunderstood this to mean that it adds +1 if branch succeeds and another +2 if to a new page.
Another source here also seems to match what you point out. I'll run some test roms and do some more digging. Thanks for pointing out!

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

No branches or pull requests

2 participants