drv/calc_num.r8asm reads 6 characters, shifts digits into a four cell ASCII
window (D3 D2 D1 D0, most significant first) and converts it with clb_undigits
whenever a non digit arrives, then resets the window to "0000".
in 12 34 out 12 34 tape 88413, 78908 steps
in 0 7 out 0 7 0 0 (each EOF read is a terminator too)
in 2047 out 2047 0
in 9999 out 1807 0 (9999 wraps mod 2048, as the machine does)
in 1234/0007 out 1234 0 / 7 0 (leading zeros work)
tape_run and derive agree on every case.
One deliberate departure from docs/calc.md: the digit branch copies the character
itself into the window instead of C - 48. clb_undigits xors each cell with 48 on
the way in, so the window has to hold ASCII -- storing the numeric value paid the
xor twice (first version: "12 34" -> 540 562, e.g. 49^48=1 but 1^48=49 then * 10 +
... lands at 540). So cell 2 (the 48 constant) and the sub_nc call are unused;
the file says so.
The window shift goes high to low (D3 <- D2 <- D1 <- D0) which is the order that
does not clobber unshifted digits; each copy is preceded by an erase of the
buffer even though this build's copy turns out to clean it itself.