Hello!
I've been working on a small NES/6502 simulator in JavaScript for the past few weeks, this forum has helped me a lot.
Today is the day I register, for a very specific question:
According to many sources/specs, conditional branches (like BEQ, BNE, BVS, BVC, ...) take:
- 2 cycles when the branch doesn't occur
- 3 cycles when the branch occurs on the same page
- 4 cycles when the branch occurs on a different page
So I implemented it like that and it seemed to work fine.
However, there is a famous NES homebrew called
nestest that aims to test every combination of addressing modes and instructions, and it comes with a handy
log file showing the status of the CPU before each opcode.
And at a certain point, nestest only counts 3 cycles during what I assume to be a cross-page BEQ:
Code:
...
CFFE: F0 05 BEQ $D005
D005: A9 AA LDA #$AA
...
Am I wrong to consider this a cross-page branch (the opcode being on $CFFE-$CFFF and the target address on $D005), or is nestest wrong to consider it a same-page branch?
If I am wrong, does it mean I should compare the first byte after the opcode (PC+2) with the target address?
Thanks a lot!