Audited all 30 %macro in asm/. The format was already followed almost
everywhere -- the doc block sits above the %macro, or above the %synth block
that generates its body -- but four things were wrong:
raw_and.r8asm the two doc blocks still carried the old names (bit_and, and)
raw_xor.r8asm raw_xor's first two parameters were typed Unit, not Cell
lib.r8asm step / back / output had no type at all ("%1: step_count")
and two files still repeated the retracted claim that set_0 only converges on 0
and 1 (raw_add_nc.r8asm, raw_add_nc4.r8asm). Those now say what set_0 really
does -- it clears the low bit -- and stay on the point that matters for a bit
level slice: A, B and the carry must be single bits because the searched
program only tracks the low K bits.
Parameter types are now a closed set: Cell, CellBit, Unit, UnitBit, Count
(Count is for step/back's repeat count). It is written down in AGENTS.md
together with the format, so the next macro has something to copy.
New r8forge_macro_docs_test checks the format instead of trusting review: a doc
block must exist, its "; Macro <name>" line must match the macro, the number
of documented parameters must equal argc, and every type must be one of the
five. Negative tested by deleting a parameter line and by renaming a block --
it reports both and exits 1.
Also fixes a real annoyance found while running the checks: %synth writes its
generated macro to the system temp directory and imports it. That write fails
intermittently on this machine (same directory, cmd can write, r8forge cannot;
cause unknown), which turned every assembly into "cannot open ...synth.r8asm".
The body is now built in memory and written to the temp directory or, if that
open fails, to the working directory, with one stderr line saying so.
Full suite green: test.r8asm 1666 characters, full_add 8/8, verify_raw_add_nc,
byte_op_test 65536x4 + 512, macro_docs_test 30/30, fibonacci prints its ten
numbers.
153 lines
1.9 KiB
Plaintext
153 lines
1.9 KiB
Plaintext
; Macro step
|
|
; %1: Count step_count
|
|
%macro step 1
|
|
%rep %1
|
|
stp
|
|
stp
|
|
%endrep
|
|
%endmacro
|
|
|
|
; Macro back
|
|
; %1: Count back_count
|
|
%macro back 1
|
|
%rep %1
|
|
btp
|
|
btp
|
|
%endrep
|
|
%endmacro
|
|
|
|
; Macro set_0
|
|
; %this: CellBit operand
|
|
%macro set_0 0
|
|
biz
|
|
flb
|
|
rnz
|
|
%endmacro
|
|
|
|
; Macro set_1
|
|
; %this: CellBit operand
|
|
%macro set_1 0
|
|
set_0
|
|
flb
|
|
%endmacro
|
|
|
|
; Macro erase
|
|
; %1: Cell operand
|
|
%macro erase 1
|
|
.anchor before_erase
|
|
.tp %1
|
|
%rep _CELL_SIZE
|
|
set_0
|
|
ror
|
|
%endrep
|
|
.tp before_erase
|
|
%endmacro
|
|
|
|
; Macro rol
|
|
; %this: Cell operand
|
|
%macro rol 0
|
|
%rep _CELL_SIZE - 1
|
|
ror
|
|
%endrep
|
|
%endmacro
|
|
|
|
|
|
|
|
; Macro clb_bit_mov
|
|
; %this: CellBit data
|
|
; %1: CellBit destination
|
|
|
|
%macro clb_bit_mov 1
|
|
.anchor before_clb_bit_mov
|
|
.tp %1
|
|
set_0
|
|
.tp before_clb_bit_mov
|
|
biz
|
|
.tp %1
|
|
flb
|
|
.tp before_clb_bit_mov
|
|
flb
|
|
rnz
|
|
.tp before_clb_bit_mov
|
|
%endmacro
|
|
|
|
|
|
; Macro bit_copy
|
|
; %this: CellBit data
|
|
; %1: CellBit destination
|
|
; %2: CellBit buffer
|
|
|
|
%macro bit_copy 2
|
|
.anchor before_bit_copy
|
|
|
|
.tp %1
|
|
set_0
|
|
.tp %2
|
|
set_0
|
|
.tp before_bit_copy
|
|
biz
|
|
.tp %1
|
|
flb
|
|
.tp %2
|
|
flb
|
|
.tp before_bit_copy
|
|
flb
|
|
rnz
|
|
.tp %2
|
|
clb_bit_mov before_bit_copy
|
|
|
|
.tp before_bit_copy
|
|
%endmacro
|
|
|
|
|
|
|
|
; Macro copy
|
|
; %this: CellBit data
|
|
; %1: CellBit destination
|
|
; %2: CellBit buffer
|
|
|
|
%macro copy 2
|
|
.anchor before_copy
|
|
%rep _CELL_SIZE
|
|
bit_copy %1 %2
|
|
ror
|
|
.tp %1
|
|
ror
|
|
.tp %2
|
|
ror
|
|
.tp before_copy
|
|
%endrep
|
|
%endmacro
|
|
|
|
|
|
; Macro bit_copy_to_buffer
|
|
; %this: UnitBit operand
|
|
; %1: CellBit tmp
|
|
%macro bit_copy_to_buffer 1
|
|
stp
|
|
.anchor bit_copy_to_buffer_buf_1
|
|
btp
|
|
bit_copy bit_copy_to_buffer_buf_1 %1
|
|
%endmacro
|
|
|
|
|
|
; Macro copy_to_buffer
|
|
; %this: Unit operand
|
|
; %1: Cell tmp
|
|
|
|
%macro copy_to_buffer 1
|
|
stp
|
|
.anchor copy_to_buffer_buf_1
|
|
btp
|
|
copy copy_to_buffer_buf_1 %1
|
|
%endmacro
|
|
|
|
; Macro output
|
|
; %1: Cell operand
|
|
|
|
%macro output 1
|
|
.anchor before_output
|
|
.tp %1
|
|
out
|
|
.tp before_output
|
|
%endmacro |