FAILURE MAP
← Case archive

FA-89358 / Instruction set emulation / Member archive

CMP clears carry on equality · case 03

Comparing equal values clears carry, so a branch on carry set after CMP misses equal operands.

Member previewVariant 3 · 3 implementations · 9 checks per implementation

Case contract

Input [a, c, ops] for an 8-bit accumulator with carry c; V starts 0. adc m: s = a+m+c, A = s & 0xFF, C = s > 0xFF, V = signed overflow of the 8-bit add. sbc m is adc of (m xor 0xFF) with the same carry (carry set means no borrow). cmp m: C = a >= m (unsigned), N/Z from (a-m) & 0xFF, A and V unchanged. After each op report [A, N, V, Z, C] where N is bit 7 and Z is result == 0.

Why this case matters

CPU emulators live or die on flag semantics; carry-as-inverted-borrow and overflow are the classic 8-bit emulation bugs.

One recorded failure

Sample boundary fixture

This sample comes from the broken implementation of a controlled reproducer.

Boundary fixtureActualExpectedOutcome
cmp orders and keeps accumulator[[64, 0, 0, 1, 0], [64, 1, 0, 0, 0], [64, 0, 0, 0, 1], [66, 0, 0, 0, 0]][[64, 0, 0, 1, 1], [64, 1, 0, 0, 0], [64, 0, 0, 0, 1], [66, 0, 0, 0, 0]]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 ↗