The nc slices do drive a rotation, so two more library macros fall out of them:
clb_add_nc A + B -> S, carry in/out in one cell 4 cells 693 chars
clb_inc_nc A + 1 -> S, carry in/out in one cell 3 cells 433 chars
against raw_add (6 cells, 1647) and raw_inc (5, 1214). Both are in
r8forge_byte_op_test now, exhaustive: 65536 and 256 combinations, all pass.
clb_inc_nc has to start its carry cell at 1 -- that bit is the "+1"; the add
version starts at 0. A rotation driver reads the low bit, throws it away and
rotates, so eating the operands is exactly what it wants.
This retracts a sentence that has been in the tree for a while: "rotation needs
A and B preserved". It does not. Preserving them is a separate wish (raw_*
grants it, with two more cells). AGENTS.md said the wrong thing in the do not
retry list; that bullet now says what was really measured, which is only that a
4 cell slice asked to *preserve* A and B has no solution up to 8 layers.
Renamed for the same reason: bit_add_nc -> clb_bit_add_nc, bit_inc_nc ->
clb_bit_inc_nc, verify_add_nc.r8asm -> verify_clb_bit_add_nc.r8asm,
verify_inc_nc.r8asm -> verify_clb_bit_inc_nc.r8asm. Measured what the prefixes
actually separate here:
bit_raw_and A=1 B=1 -> cells 0=1 1=1 2=1 operands preserved, has tmp
bit_raw_add A=1 B=1 -> cells 0=1 1=1 4=1 operands preserved, has buf
clb_bit_and A=1 B=1 -> cells 2=1 operands eaten, no tmp
clb_bit_add_nc A=1 B=1 -> cells 2=1 3=1 operands eaten, no tmp
so raw means "the caller passes the scratch cell" and those variants happen to
keep their inputs, while clb means the inputs are gone. These slices eat A and
B, so they are clb.
One self inflicted mess to own up to: I rewrote AGENTS.md with a PowerShell
Get-Content / Set-Content round trip, which on this machine decodes UTF-8 as GBK
and wrote the file back as mojibake. Restored it with git checkout -- AGENTS.md
and redid every edit through the editor. The work rule in AGENTS.md now names
that exact trap instead of only warning about -Encoding ascii.
Green: test.r8asm 1666, full_add 8/8, both verify_*.r8asm, byte_op_test
(65536x4 + 512 + 65536 + 256), macro_docs_test 32 macros in 10 files, fibonacci.
19 lines
383 B
Plaintext
19 lines
383 B
Plaintext
%include "asm/raw_add_nc.r8asm"
|
|
|
|
; clb_add_nc 的字节级驱动:操作数直接放在 A、B 里,不预置任何常量。
|
|
;
|
|
; r8forge_derive drv/raw_add_nc_byte.r8asm -2 0=5 2=3
|
|
;
|
|
; out 依次是 A、B、S、Ci。和 raw_add 的驱动不同,A、B 是被吃掉的(结束为 0)。
|
|
.var A 0
|
|
.var Ci 1
|
|
.var B 2
|
|
.var S 4
|
|
|
|
clb_add_nc A B S Ci
|
|
|
|
output A
|
|
output B
|
|
output S
|
|
output Ci
|