FA-89386 / Instruction set emulation / Open access
Taken branch charged as not taken · case 01
Taken branches cost one cycle too few.
ROOT CAUSE
The taken-branch base cycle count is the not-taken count.
THE FAILURE
The taken-branch base cycle count is the not-taken count.
Unsuccessful approach: Treating a zero displacement as not taken still undercounts that branch.
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.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
pc, disp, taken = args
nxt = (pc + 2) & 0xFFFF
if not taken:
return [nxt, 2]
off = disp - 256 if disp >= 128 else disp
tgt = (nxt + off) & 0xFFFF
cyc = 2 + (1 if (tgt & 0xFF00) != (nxt & 0xFF00) else 0)
return [tgt, cyc]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('forward branch same page', [4097, 16, True], [4115, 3]), ('backward branch', [4224, 239, True], [4209, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4337, 32, True], [4371, 4]), ('backward page crossing from next page start', [16638, 253, True], [16637, 4]), ('branch not taken', [20481, 64, False], [20483, 2]), ('wrap below zero', [2, 129, True], [65413, 4]), ('wrap above top', [65520, 126, True], [112, 4]), ('zero displacement taken', [24577, 0, True], [24579, 3])], [('forward branch same page', [4098, 16, True], [4116, 3]), ('backward branch', [4224, 238, True], [4208, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4338, 32, True], [4372, 4]), ('backward page crossing from next page start', [16638, 252, True], [16636, 4]), ('branch not taken', [20482, 64, False], [20484, 2]), ('wrap below zero', [2, 130, True], [65414, 4]), ('wrap above top', [65520, 125, True], [111, 4]), ('zero displacement taken', [24578, 0, True], [24580, 3])], [('forward branch same page', [4099, 16, True], [4117, 3]), ('backward branch', [4224, 237, True], [4207, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4339, 32, True], [4373, 4]), ('backward page crossing from next page start', [16638, 251, True], [16635, 4]), ('branch not taken', [20483, 64, False], [20485, 2]), ('wrap below zero', [2, 131, True], [65415, 4]), ('wrap above top', [65520, 124, True], [110, 4]), ('zero displacement taken', [24579, 0, True], [24581, 3])], [('forward branch same page', [4100, 16, True], [4118, 3]), ('backward branch', [4224, 236, True], [4206, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4340, 32, True], [4374, 4]), ('backward page crossing from next page start', [16638, 250, True], [16634, 4]), ('branch not taken', [20484, 64, False], [20486, 2]), ('wrap below zero', [2, 132, True], [65416, 4]), ('wrap above top', [65520, 123, True], [109, 4]), ('zero displacement taken', [24580, 0, True], [24582, 3])], [('forward branch same page', [4101, 16, True], [4119, 3]), ('backward branch', [4224, 235, True], [4205, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4341, 32, True], [4375, 4]), ('backward page crossing from next page start', [16638, 249, True], [16633, 4]), ('branch not taken', [20485, 64, False], [20487, 2]), ('wrap below zero', [2, 133, True], [65417, 4]), ('wrap above top', [65520, 122, True], [108, 4]), ('zero displacement taken', [24581, 0, True], [24583, 3])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| forward branch same page | [4115, 2] | [4115, 3] | Failed |
| backward branch | [4209, 2] | [4209, 3] | Failed |
| most negative displacement | [8210, 2] | [8210, 3] | Failed |
| largest positive displacement | [12417, 2] | [12417, 3] | Failed |
| forward page crossing | [4371, 3] | [4371, 4] | Failed |
| backward page crossing from next page start | [16637, 3] | [16637, 4] | Failed |
| branch not taken | [20483, 2] | [20483, 2] | Passed |
| wrap below zero | [65413, 3] | [65413, 4] | Failed |
| wrap above top | [112, 3] | [112, 4] | Failed |
| zero displacement taken | [24579, 2] | [24579, 3] | Failed |
SHA-256 / c8b67f5bf507ad28d4514892c47b2381b36a65aaba5464341b049f1d469476a3
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
pc, disp, taken = args
nxt = (pc + 2) & 0xFFFF
if not taken:
return [nxt, 2]
off = disp - 256 if disp >= 128 else disp
tgt = (nxt + off) & 0xFFFF
cyc = (3 if off else 2) + (1 if (tgt & 0xFF00) != (nxt & 0xFF00) else 0)
return [tgt, cyc]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('forward branch same page', [4097, 16, True], [4115, 3]), ('backward branch', [4224, 239, True], [4209, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4337, 32, True], [4371, 4]), ('backward page crossing from next page start', [16638, 253, True], [16637, 4]), ('branch not taken', [20481, 64, False], [20483, 2]), ('wrap below zero', [2, 129, True], [65413, 4]), ('wrap above top', [65520, 126, True], [112, 4]), ('zero displacement taken', [24577, 0, True], [24579, 3])], [('forward branch same page', [4098, 16, True], [4116, 3]), ('backward branch', [4224, 238, True], [4208, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4338, 32, True], [4372, 4]), ('backward page crossing from next page start', [16638, 252, True], [16636, 4]), ('branch not taken', [20482, 64, False], [20484, 2]), ('wrap below zero', [2, 130, True], [65414, 4]), ('wrap above top', [65520, 125, True], [111, 4]), ('zero displacement taken', [24578, 0, True], [24580, 3])], [('forward branch same page', [4099, 16, True], [4117, 3]), ('backward branch', [4224, 237, True], [4207, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4339, 32, True], [4373, 4]), ('backward page crossing from next page start', [16638, 251, True], [16635, 4]), ('branch not taken', [20483, 64, False], [20485, 2]), ('wrap below zero', [2, 131, True], [65415, 4]), ('wrap above top', [65520, 124, True], [110, 4]), ('zero displacement taken', [24579, 0, True], [24581, 3])], [('forward branch same page', [4100, 16, True], [4118, 3]), ('backward branch', [4224, 236, True], [4206, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4340, 32, True], [4374, 4]), ('backward page crossing from next page start', [16638, 250, True], [16634, 4]), ('branch not taken', [20484, 64, False], [20486, 2]), ('wrap below zero', [2, 132, True], [65416, 4]), ('wrap above top', [65520, 123, True], [109, 4]), ('zero displacement taken', [24580, 0, True], [24582, 3])], [('forward branch same page', [4101, 16, True], [4119, 3]), ('backward branch', [4224, 235, True], [4205, 3]), ('most negative displacement', [8336, 128, True], [8210, 3]), ('largest positive displacement', [12288, 127, True], [12417, 3]), ('forward page crossing', [4341, 32, True], [4375, 4]), ('backward page crossing from next page start', [16638, 249, True], [16633, 4]), ('branch not taken', [20485, 64, False], [20487, 2]), ('wrap below zero', [2, 133, True], [65417, 4]), ('wrap above top', [65520, 122, True], [108, 4]), ('zero displacement taken', [24581, 0, True], [24583, 3])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| forward branch same page | [4115, 3] | [4115, 3] | Passed |
| backward branch | [4209, 3] | [4209, 3] | Passed |
| most negative displacement | [8210, 3] | [8210, 3] | Passed |
| largest positive displacement | [12417, 3] | [12417, 3] | Passed |
| forward page crossing | [4371, 4] | [4371, 4] | Passed |
| backward page crossing from next page start | [16637, 4] | [16637, 4] | Passed |
| branch not taken | [20483, 2] | [20483, 2] | Passed |
| wrap below zero | [65413, 4] | [65413, 4] | Passed |
| wrap above top | [112, 4] | [112, 4] | Passed |
| zero displacement taken | [24579, 2] | [24579, 3] | Failed |
SHA-256 / 172c62d645471bea3475644b691409f31950d65977451f7fc9d1134784c92397
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 10 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic bounded teaching model of one emulator rule; the instruction semantics are a stipulated contract inspired by common ISAs and are not a claim of cycle-exact or architectural conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:51:16.862168+00:00.
Case digest / fda86fead94aa003afb88defcc576ef3fec7d9324fc1dd30331d9d11de3677dc