Closed qookei closed 1 year ago
Having had a peek, the problem was even greater than this — per the relevant typo I'm pretty sure the extra cycle was being skipped where the target page is equal to the relative jump, e.g. BRA $03
would skip a cycle if the target was in page $03
. Very dumb.
The linked pull request is intended to fix the problem, though I've yet to do any manual verification.
PR #30 makes all the branch instruction tests pass in my emulator now
For example, in test "80 e 10000", 2 stall cycles are expected at the end despite the target not crossing a page:
In that test, the initial PC is
$8943
, branch offset is$72
, and final PC is$89b7
, which AFAICU does not constitute a crossing of the page boundary (($8943 & $ff00) == ($89b7 & $ff00)
), which is also the case according to the 65816 emulator cores I've checked (the ones in mesen2, bsnes, and snes9x).Perhaps I am fundamentally misunderstanding how page crossing is determined, but this appears to affect ~75% of tests in
80.e.json
:EDIT: For reference, here's my code that handles branches: