1 Commits
Author SHA1 Message Date
dsh 4be8aa15ad Byte level add and increment with 4 and 3 cells: clb_*_nc
The nc slices do drive a rotation, so two more library macros fall out of them:

    clb_add_nc  A + B -> S, carry in/out in one cell   4 cells   693 chars
    clb_inc_nc  A + 1 -> S, carry in/out in one cell   3 cells   433 chars

against raw_add (6 cells, 1647) and raw_inc (5, 1214).  Both are in
r8forge_byte_op_test now, exhaustive: 65536 and 256 combinations, all pass.
clb_inc_nc has to start its carry cell at 1 -- that bit is the "+1"; the add
version starts at 0.  A rotation driver reads the low bit, throws it away and
rotates, so eating the operands is exactly what it wants.

This retracts a sentence that has been in the tree for a while: "rotation needs
A and B preserved".  It does not.  Preserving them is a separate wish (raw_*
grants it, with two more cells).  AGENTS.md said the wrong thing in the do not
retry list; that bullet now says what was really measured, which is only that a
4 cell slice asked to *preserve* A and B has no solution up to 8 layers.

Renamed for the same reason: bit_add_nc -> clb_bit_add_nc, bit_inc_nc ->
clb_bit_inc_nc, verify_add_nc.r8asm -> verify_clb_bit_add_nc.r8asm,
verify_inc_nc.r8asm -> verify_clb_bit_inc_nc.r8asm.  Measured what the prefixes
actually separate here:

    bit_raw_and  A=1 B=1 -> cells 0=1 1=1 2=1   operands preserved, has tmp
    bit_raw_add  A=1 B=1 -> cells 0=1 1=1 4=1   operands preserved, has buf
    clb_bit_and  A=1 B=1 -> cells 2=1           operands eaten, no tmp
    clb_bit_add_nc A=1 B=1 -> cells 2=1 3=1     operands eaten, no tmp

so raw means "the caller passes the scratch cell" and those variants happen to
keep their inputs, while clb means the inputs are gone.  These slices eat A and
B, so they are clb.

One self inflicted mess to own up to: I rewrote AGENTS.md with a PowerShell
Get-Content / Set-Content round trip, which on this machine decodes UTF-8 as GBK
and wrote the file back as mojibake.  Restored it with git checkout -- AGENTS.md
and redid every edit through the editor.  The work rule in AGENTS.md now names
that exact trap instead of only warning about -Encoding ascii.

Green: test.r8asm 1666, full_add 8/8, both verify_*.r8asm, byte_op_test
(65536x4 + 512 + 65536 + 256), macro_docs_test 32 macros in 10 files, fibonacci.
2026-11-07 09:03:08 +08:00