Files
R8Forge/drv/digits.r8asm
dsh d0fd127048 build: the 32 bit toolchain builds, and 8/16 bit byte tests really pass
Two separate things hid behind "32 bit works":

* tests/byte_op_test.cc could not compile at 32 bits at all (`1 << 32` in a
  constexpr plus an int typed mask), so the whole 32 bit build stopped there --
  only `r8forge` and the core library came out.  kCellMod is now clamped at
  31+ bits and main() prints "skipped" above 16 bits (every sweep there is 2^W
  rows) and exits green.  All ten targets build at 32 bits with MSVC, and the
  same tree builds clean on a Gentoo box with GCC 16 -- the missing <cstring>
  in asm_test.cc that stopped GCC first is in the previous commit.
* the digit drivers hardcoded a 4 cell window, so byte_op_test's digits /
  digits_signed / undigits failed at every other width (16 bits wants 5 digits,
  8 bits 3).  drv/digits.r8asm, drv/digits_signed.r8asm and
  drv/undigits_byte.r8asm now derive D = _CELL_SIZE * 30103 / 100000 + 1 and
  space their cells by it, and the C++ side uses the same kDigits instead of a
  literal 4 (including the T/F cells clb_digits_signed leaves behind).

With that, byte_op_test passes at 8, 11 and 16 bits (the 16 bit run takes about
450 s) and above 16 it skips.  Two more width bugs fell out on the way: the
divmod divisor sweep used 1000 and 2047 unconditionally (they wrap at 8 bits),
and the undigits garbage guard OR'ed in bits above the cell, which at 8 bits
turned '0'+digit into a value over 255.  test_divmod_signed also divided by the
recovered divisor without re-checking it, and at 8 bits the boundary value 1024
wraps to 0 -- that was a hard crash (divide by zero), not a failure.

CMakeLists.txt now refuses -DR8FORGE_CELL_SIZE outside 1..32 at configure time;
the range used to be a comment, so an out of range width was discovered as a
compiler error in whichever file shifted by it first.  geometry.hh and SPEC
section 13 record that 32 is the ceiling because every VM stores a cell in
uint32_t -- going further means widening all five VMs, the assembler's immediate
type and ROT-8-viz's rot8_data.

Also recorded there: the %synth cache is keyed by the truth table, not the
width, so a 32 bit build hits the committed entries (0.4 s for the flagship
tape of 227075 characters).  A full cold rebuild takes ~500 s on a 44 thread
machine, 479 s of which is the single 6 parameter full adder table.
2026-11-19 13:41:59 +08:00

23 lines
837 B
Plaintext

%include "asm/digits.r8asm"
; clb_digits 的驱动:0 号 cell 放值,1 起是 D 位输出区域,再往后是草稿。
;
; r8forge_derive drv/digits.r8asm -1 0=2047 # 11 位: 50 48 52 55 = "2047"
; r8forge_derive drv/digits.r8asm -1 0=7 # 11 位: 48 48 48 55 = "0007"
;
; D = _CELL_SIZE * 30103 / 100000 + 1 是十进制位数(11 位下 4、16 位下 5、8 位下 3),
; 所以地址跟着位宽走:REG 占 1..1+D-1,草稿从 1+D 开始。**别把 D 写死 4** ——
; 写死了 16 位下就会拿 5 位数字去撞草稿区(r8forge_byte_op_test 的 16 位那一轮
; 以前就是这么错的)。
; out 依次是区域 D 格(ASCII 码,所以 48 是 '0')。
.var D _CELL_SIZE * 30103 / 100000 + 1
.var N 0
.var REG 1
.var S 1 + D
clb_digits N REG S
%for k D
output REG + k
%endfor