FA-89377 / Instruction set emulation / Member archive
Branch target escapes the 16-bit address space · case 02
Branches near address 0 or 0xFFFF produce negative or 17-bit targets.
Case contract
Input [pc, disp, taken] for a 2-byte conditional branch at pc in a 16-bit address space. The next instruction is (pc+2) & 0xFFFF; disp is an 8-bit two's complement offset from that address. Not taken: [next, 2]. Taken: target = (next + offset) & 0xFFFF and cost 3 cycles plus 1 when target and next lie on different 256-byte pages. Return [pc', cycles].
Why this case matters
Branch emulation must use the post-fetch PC, sign-extend the offset and charge page-crossing cycles exactly.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| wrap below zero | [-122, 4] | [65414, 4] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗