Borrow-Ladder Odometer
Big NumbersA 128-bit number counting down — subtracted limb by limb, the borrow rippling upward like an odometer rolling past zero. This is compiler stress-test #110: eight limbs exercise native-width subtract-with-borrow code generation on every tick.
Self-running — a 128-bit binary counter ticks down, borrows rippling upward.
Source borrowlad.cborrowlad.h in wbniv/llvm-mos-65816
What it is
Numbers wider than the machine word are done in pieces, and subtraction threads a borrow from the bottom piece to the top. This demo keeps that chain busy across eight 16-bit limbs.
// subtract two 128-bit numbers, limb by limb, borrow rippling upward
uint16_t borrow = 0;
for (int i = 0; i < 8; i++) {
int32_t t = a[i] - b[i] - borrow;
a[i] = (uint16_t)t;
borrow = (t < 0) ? 1 : 0;
} Each frame subtracts a large decrement, so borrows cascade through all eight limbs. The gate folds the value into a CRC; a wrong borrow breaks both the countdown and the CRC.
Compiler stress-test #110
| Item | What it exercises |
|---|---|
| subtracting big numbers | A 128-bit number is stored as eight 16-bit pieces and subtraction propagates a borrow from one limb to the next. |
| native-width codegen | The +mos-a16 and +mos-xy16 builds exercise the 65816 subtract-with-borrow path; default 8-bit codegen remains the differential oracle. |
| exact by construction | A single dropped or duplicated borrow changes the CRC. The gate requires host == default == +mos-a16 == +mos-xy16 with clean machine verification. |
| the visual | The 128 bits are shown as a grid — bright for 1, dark for 0 — so low-bit churn and upward borrow ripples are visible. |
Written in C with the llvm-mos 65816 toolchain and verified against bsnes-jg and MAME.
Hit Verify fidelity to reproduce the build gate's WRAM assert
(gate CRC 0x1BE3 — a fold of 160 countdown steps) live in this tab.
No far pointers — host == default == +mos-a16 == +mos-xy16,
-verify clean.