Files
R8Forge/.r8forge_cache/1a6abdeead659b5f.txt
dsh 13b831ec8b A 4 cell adder slice: the carry borrows the scratch cell
Asked why the slice still needs 5 cells.  It does not: the scratch cell was
doing nothing the carry could not do, so the 4 cell version is

    p1..p4 = A, B, carry (in -> out), S

and the table says S = A^B^Ci, carry = AB|AC|BC, A and B consumed.  %synth
finds cost 27 in 5 blocks for it -- the same tape length as the 5 cell version
(cell count is not part of the cost metric, only the instructions are) but one
cell cheaper, 73 characters for a single slice.

All eight input combinations verified through the built in machine.

Diagnosis of the chained hang, from dumping the cells after one slice plus the
ror rotation:

    A=1 B=0  ->  cells: 4=80        (only the rotated sum bit survives)
    A=1 B=1  ->  cells: 1=1         (only the carry)

so a slice leaves A and B fully clear, and the carry is a clean 0/1.  The dirty
one is S: after the rotation its bit 7 is set, and set_0 in the next slice does
not remove it -- the dump after two slices shows 4=81 and, worse, the tape then
runs off the end instead of reaching 'output S'.

So the fix is not in the slice but in the driver: it must not rotate the sum
into a cell that the next slice clears, or must clear the whole cell (set_cell,
not set_0 over the modelled bits).  That is the next step, together with
re-checking whether set_0 is the right primitive here at all.
2026-11-06 21:31:04 +08:00

7 lines
58 B
Plaintext

# params 4 mode 0 metric 1
2 9 0
0 6 0
1 9 0
3 4 1
0 12 0