Files
R8Forge/drv
dsh f9821f8989 calc: stage 4 verified -- four operations, one shared scratch block
drv/calc_op.r8asm computes one case per operation and displays it with the stage 3
prompt, so the arithmetic path of the calculator is proven:

    +  12 34  ->  46        *  12 34   -> 408
    -  100 30 ->  70        /  2047 3  -> 682

    out 62 32 48 48 52 54 10 | 62 32 48 48 55 48 10
        62 32 48 52 48 56 10 | 62 32 48 54 56 50 10

tape 77356 characters, 599090 steps, tape_run and derive agree on all 28 values.

The useful result is the memory map: the four macros want different scratch, and
one 7 cell block (23..29) serves all of them -- add/sub use its first cell as the
carry, clb_mul uses exactly those 7 as Ci PH MCA S T F NR, clb_divmod uses the same
7 as its S.  They never run at the same time, so one erase before each call does
for all three.  The result cell is the display's N cell directly (add/sub write S
there, mul writes PL, divmod writes Q), which saves a copy per case.

Contract probes confirm SPEC: add leaves the carry output 0, sub reports no-borrow
1, mul keeps MC and eats MUL, divmod keeps N and D and puts the remainder in R.

Over ROT-8-viz's 65536 limit (four expanded clb_digits blocks), so it is verified
through the two r8forge machines only; stage 5 loops the display, so the real
calculator will be smaller than this.
2026-11-11 11:18:41 +08:00
..