r8forge_tape_run grew a `--trace` flag: it prints pc, instruction, dp and the
first four cells before every step. Without it a wrong hand written macro is
just "the answer is wrong"; with it the failure is one line, e.g. dp jumping to
1023 because a backwards move was emitted where the runtime was already there.
That is what happened to the two cell in place increment I tried after the in
place complement. It assembled to 155 characters (against 430 for the slice
version) and got 129 of 256 inputs right -- every input whose low bit is 0, i.e.
every input that never propagates a carry. The algorithm was fine; the macros
were not.
The rule it broke: dp is a compile time constant in r8asm while a `[ ... ]` body
may be skipped at run time, so **every conditional body has to come back to its
own condition cell** (net zero moves). Otherwise the taken and the skipped path
leave dp in different places and every later `.tp` is off by one. The library
already obeys this: set_0's body never moves, clb_bit_mov ends with `.tp before`
and a `flb` that eats the condition on the way out.
For a two cell in place add both candidate condition cells hold live data (A's
bit is the result, the carry cell's bit is the carry), so each test first has to
make its condition consumable, which means moving a bit through the spare bits of
the carry cell and rotating it into place -- about eight characters of detour per
bit. A correct version should land near 200-220 characters, still about half of
the 430 character slice version, but it stays a hand written loop with subtle
invariants. Not added to the library yet; the scratch files are gone.
AGENTS.md now carries the dp rule under the instruction semantics section, next
to the two `set_0` / `%synth` constraints it belongs with.