Files
R8Forge/asm
dsh eedd9a33a6 Negate and subtract invert the whole byte first instead of bit by bit
Asked why an in place complement does not exist, given that in place inversion
does.  The inversion half is now hoisted out of the per bit loop, which is both
simpler and shorter:

    clb_neg_nc A S Ci = clb_not_ip A ; clb_inc_nc A S Ci     468 -> 448
    clb_sub_nc A B S Ci = clb_not_ip B ; clb_add_nc A B S Ci   725 -> 707

and the unsigned complement through the same macro (carry in at 0) drops 467 ->
447.  B is eaten by the add anyway, so inverting it in place costs nothing.  The
per bit `flb` wrappers (clb_bit_neg_nc, clb_bit_sub_nc) are gone with them, so
macro_docs_test now counts 35 macros.

What does not work is the other half: there is no in place increment, so the sum
still has to land in S.  Two independent reasons, both written down:

* A synthesised block has exactly one condition cell, so it cannot tell
  (A=1, Ci=0) from (A=1, Ci=1) -- and that distinction is the whole carry rule.
  All four in place tables answer "no program up to 8 layers".
* Hand writing cannot do it with two cells either: `[ ... ]` is the only one shot
  conditional this ISA has, and it eats the bit it tests, while in place
  increment needs both cells' bits alive at the same time.

So one cell buys the ones' complement only; a two's complement negate costs three
(A, S, carry).  tests unchanged and green: ten byte level operations, 1666
character test tape, 8/8 full adder, fibonacci.

Also: the docs quoted clb_neg_nc at 468 and clb_sub_nc at 725, now 448 and 707.
2026-11-07 09:20:44 +08:00
..