Files
R8Forge/asm
dsh b962c345c8 clb_digits: derive the digit count from _CELL_SIZE
The round count was spelled out as four 1s in the counter; it is a function of
the cell width (L = floor(W*log10(2)) + 1, integer approximated as
W*30103/100000 + 1, which gives 3/4/5/10 for 8/11/16/32 bits), and r8asm
evaluates that inside %rep, so the counter now builds itself:

    %rep _CELL_SIZE * 30103 / 100000
        rol
        set_1
    %endrep

What is still spelled out is the shift chain (three copies with distinct
offsets), because each step names a different cell and r8asm has no %if, no
indexed %rep and no recursion -- it cannot emit L-1 different instruction
groups.  So the macro is correct for _CELL_SIZE == 11 only, and the comment now
says so loudly: a 16 bit cell needs one more step and one more cell, otherwise
the result is silently wrong.  Making it generic needs an indexed %for in the
assembler (or a ten cell region with a fixed nine step chain, which works at
any width but costs three thousand characters and six cells).

All eleven values still correct at 11 bits, 13743 characters with the driver.
2026-11-07 17:55:39 +08:00
..