A synth block used to spell out which parameter is an input and which is an output. That was redundant: with map, 2^K entries already mean %1..%K are the inputs and the value's bits land on the parameters after them; with a raw table, nothing needs saying at all. So 'inputs' and 'outputs' now fail with a message pointing at map/stat, and the map form derives both. Added 'stat' as the fully explicit form: 2^params values, one per input combination, which is exactly the state table the search consumes. examples/full_add_stat.r8asm is the same adder written that way and produces a byte-identical tape to the map version (95 characters), both pass the eight combination check.
26 lines
568 B
Plaintext
26 lines
568 B
Plaintext
%include "asm/lib.r8asm"
|
|
|
|
; 让汇编器在汇编期合成一个全加器 bit-slice。
|
|
; %1 %2 %3 = A B Ci 输入(必须是最前面的参数)
|
|
; %4 %5 = S Co 要被算出来的输出
|
|
; %6 = T 草稿 cell,调用方给一个,结束时它必须是 0
|
|
;
|
|
; map 的每一项是那个输入组合下 %4%5 的取值(bit0 = %4, bit1 = %5),
|
|
; 顺序是输入组合 000,001,...,111。
|
|
%synth fulladd
|
|
params 6
|
|
map 0 1 1 2 1 2 2 3
|
|
%endsynth
|
|
|
|
.var A 0
|
|
.var B 1
|
|
.var Ci 2
|
|
.var S 3
|
|
.var Co 4
|
|
.var T 5
|
|
|
|
fulladd A B Ci S Co T
|
|
|
|
output S
|
|
output Co
|