An error in the branch test

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
ashkalov
Posts: 9
Joined: Thu May 14, 2020 3:58 am

An error in the branch test

Post by ashkalov » Tue Aug 25, 2020 10:19 pm

Hello.
If I understand correctly, then to execute the branch instruction:
If the jump was not made, then the instruction takes 2 cycles.
If the transition was made, +1 cycle = 3 cycles.
If boundary is crossed, +1 cycle = 4 cycles

I am using the "2.Backward_Branch.nes" test.
It gives the error "5) Branch from $ E5FE to $ E5FD is too short".
test_error.PNG
I checked that my transition from $ E5FE to $ E5FD takes 3 cycles.

What's wrong?
There is no intersection, why does he want 4 cycles?
Nostalgia is our little time machine

User avatar
tokumaru
Posts: 11858
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: An error in the branch test

Post by tokumaru » Tue Aug 25, 2020 10:27 pm

I assume that what's happening here is that since the branch instruction is at address $E5FE, and it uses 2 bytes, by the time the instruction has been fetched the PC is already at address $E600, so it does indeed need to cross the page in order to jump back.

User avatar
ashkalov
Posts: 9
Joined: Thu May 14, 2020 3:58 am

Re: An error in the branch test

Post by ashkalov » Tue Aug 25, 2020 10:52 pm

Thank you very much! Everything is exactly as you said!
Nostalgia is our little time machine

Post Reply