From ebe98fdfa87175d5d275c68519eda4e679bc886f Mon Sep 17 00:00:00 2001 From: StarCells Date: Sun, 13 Sep 2026 12:17:41 +0800 Subject: [PATCH] [err]202609131217 --- asm/lib.r8asm | 10 +++ asm/{add.r8asm => raw_add.r8asm} | 1 - asm/{and.r8asm => raw_and.r8asm} | 102 ++++++++++++++------------- asm/{inc.r8asm => raw_inc.r8asm} | 33 ++++----- asm/{or.r8asm => raw_or.r8asm} | 116 ++++++++++++++++--------------- asm/{xor.r8asm => raw_xor.r8asm} | 92 +++++++++++++----------- asm/test.r8asm | 54 ++++++++------ 7 files changed, 219 insertions(+), 189 deletions(-) rename asm/{add.r8asm => raw_add.r8asm} (99%) rename asm/{and.r8asm => raw_and.r8asm} (56%) rename asm/{inc.r8asm => raw_inc.r8asm} (76%) rename asm/{or.r8asm => raw_or.r8asm} (51%) rename asm/{xor.r8asm => raw_xor.r8asm} (57%) diff --git a/asm/lib.r8asm b/asm/lib.r8asm index 5d1f500..265932b 100644 --- a/asm/lib.r8asm +++ b/asm/lib.r8asm @@ -140,4 +140,14 @@ stp .anchor copy_to_buffer_buf_1 btp copy copy_to_buffer_buf_1 %1 +%endmacro + +; Macro output +; %1: operand + +%macro output 1 +.anchor before_output +.tp %1 +out +.tp before_output %endmacro \ No newline at end of file diff --git a/asm/add.r8asm b/asm/raw_add.r8asm similarity index 99% rename from asm/add.r8asm rename to asm/raw_add.r8asm index 91a4041..2e746d7 100644 --- a/asm/add.r8asm +++ b/asm/raw_add.r8asm @@ -103,7 +103,6 @@ rnz %macro raw_add 6 .anchor before_raw_add -erase %6 .tp %3 bit_copy %6 %5 .tp %6 diff --git a/asm/and.r8asm b/asm/raw_and.r8asm similarity index 56% rename from asm/and.r8asm rename to asm/raw_and.r8asm index 8cf00f1..31806db 100644 --- a/asm/and.r8asm +++ b/asm/raw_and.r8asm @@ -48,74 +48,76 @@ rnz ; Macro bit_and -; %1: UnitBit arg1 -; %2: UnitBit arg2 +; %1: CellBit arg1 +; %2: CellBit arg2 ; %3: CellBit ans -%macro bit_and 3 -.anchor before_and - -.tp %1 + 1 -.anchor bit_and_buf_1 -.tp %2 + 1 -.anchor bit_and_buf_2 - +; %4: CellBit tmp +%macro bit_and 4 +.anchor before_bit_and .tp %3 -set_0 -.tp bit_and_buf_1 -set_0 -.tp bit_and_buf_2 -set_0 +biz + flb +rnz + +.tp %4 +biz + flb +rnz + .tp %1 biz - .tp %3 - set_1 - .tp bit_and_buf_1 - set_1 - .tp %1 - flb + .tp %3 + set_1 + .tp %4 + set_1 + .tp %1 + flb rnz + .tp %2 biz - .tp %1 - set_1 - .tp %3 - set_1 - .tp %2 - flb -rnz -.tp %1 -biz - .tp %2 - flb - .tp %3 - flb - .tp %1 - flb -rnz -.tp bit_and_buf_1 -biz - .tp %1 - flb - .tp %3 - flb - .tp bit_and_buf_1 - flb + .tp %1 + set_1 + .tp %3 + set_1 + .tp %2 + flb rnz -.tp before_and +.tp %1 +biz + .tp %2 + flb + .tp %3 + flb + .tp %1 + flb +rnz + +.tp %4 +biz + .tp %1 + flb + .tp %3 + flb + .tp %4 + flb +rnz +.tp before_bit_and %endmacro ; Macro and -; %1: Unit arg1 -; %2: Unit arg2 +; %1: Cell arg1 +; %2: Cell arg2 ; %3: Cell ans -%macro and 3 +; %4: CellBit tmp +%macro raw_and 4 .anchor before_and %rep _CELL_SIZE - bit_and %1 %2 %3 + bit_and %1 %2 %3 %4 .tp %1 ror .tp %2 diff --git a/asm/inc.r8asm b/asm/raw_inc.r8asm similarity index 76% rename from asm/inc.r8asm rename to asm/raw_inc.r8asm index ac3df13..c3c1164 100644 --- a/asm/inc.r8asm +++ b/asm/raw_inc.r8asm @@ -1,10 +1,7 @@ -; TODO - - -%include asm/lib.r8asm -; Macro inc +%include "asm/lib.r8asm" +; Macro bit_raw_inc ; %1: CellBit A -; %2: CellBit B +; %2: CellBit Ci ; %3: CellBit S ; %4: CellBit Co ; %5: CellBit tmp @@ -63,38 +60,34 @@ rnz ; Macro raw_inc ; %1: Cell A -; %2: Cell B +; %2: CellBit Ci ; %3: Cell S -; %4: Cell Co +; %4: CellBit Co ; %5: Cell tmp %macro raw_inc 5 .anchor before_raw_inc -.tp %5 -erase .tp %2 bit_copy %5 %4 .tp %5 ror %rep _CELL_SIZE - bit_raw_add %1 %2 %3 %4 %5 - .tp %5 - clb_bit_mov %3 + bit_raw_inc %1 %2 %3 %4 %5 + .tp %4 + clb_bit_mov %2 .tp %1 ror - .tp %2 - ror - .tp %4 + .tp %3 ror %endrep -.tp %3 -clb_bit_mov %5 +.tp %2 +clb_bit_mov %4 .tp %5 rol -clb_bit_mov %3 +clb_bit_mov %2 -.tp before_raw_add +.tp before_raw_inc %endmacro \ No newline at end of file diff --git a/asm/or.r8asm b/asm/raw_or.r8asm similarity index 51% rename from asm/or.r8asm rename to asm/raw_or.r8asm index 6d24172..c18f690 100644 --- a/asm/or.r8asm +++ b/asm/raw_or.r8asm @@ -49,75 +49,79 @@ rnz -; Macro bit_or -; %1: UnitBit arg1 -; %2: UnitBit arg2 +; Macro bit_raw_or +; %1: CellBit arg1 +; %2: CellBit arg2 ; %3: CellBit ans -%macro bit_or 3 -.anchor before_or - -.tp %1 + 1 -.anchor bit_or_buf_1 -.tp %2 + 1 -.anchor bit_or_buf_2 +; %4: CellBit tmp +%macro bit_raw_or 3 +.anchor before_bit_raw_or .tp %3 -set_0 -.tp bit_or_buf_1 -set_0 -.tp bit_or_buf_2 -set_0 +biz + flb +rnz + +.tp %4 +biz + flb +rnz + .tp %1 biz - .tp %3 - set_1 - .tp %1 - flb -rnz -.tp %3 -biz - .tp %1 - flb - .tp %2 - flb - .tp bit_or_buf_1 - flb - .tp %3 - flb -rnz -.tp %2 -biz - .tp %3 - flb - .tp bit_or_buf_1 - flb - .tp %2 - flb -rnz -.tp bit_or_buf_1 -biz - .tp %2 - set_1 - .tp %3 - set_1 - .tp bit_or_buf_1 - flb + .tp %3 + set_1 + .tp %1 + flb rnz -.tp before_or +.tp %3 +biz + .tp %1 + flb + .tp %2 + flb + .tp %4 + flb + .tp %3 + flb +rnz + +.tp %2 +biz + .tp %3 + flb + .tp %4 + flb + .tp %2 + flb +rnz + +.tp %4 +biz + .tp %2 + set_1 + .tp %3 + set_1 + .tp %4 + flb +rnz + +.tp before_bit_raw_or %endmacro -; Macro or -; %1: Unit arg1 -; %2: Unit arg2 +; Macro raw_or +; %1: Cell arg1 +; %2: Cell arg2 ; %3: Cell ans -%macro or 3 -.anchor before_or +; %4: CellBit tmp +%macro raw_or 4 +.anchor before_raw_or %rep _CELL_SIZE - bit_or %1 %2 %3 + bit_raw_or %1 %2 %3 %4 .tp %1 ror .tp %2 @@ -125,5 +129,5 @@ rnz .tp %3 ror %endrep -.tp before_or +.tp before_raw_or %endmacro \ No newline at end of file diff --git a/asm/xor.r8asm b/asm/raw_xor.r8asm similarity index 57% rename from asm/xor.r8asm rename to asm/raw_xor.r8asm index 8412877..09d97ae 100644 --- a/asm/xor.r8asm +++ b/asm/raw_xor.r8asm @@ -50,53 +50,61 @@ rnz ; Macro bit_xor -; %1: UnitBit arg1 -; %2: UnitBit arg2 +; %1: CellBit arg1 +; %2: CellBit arg2 ; %3: CellBit ans -%macro bit_xor 3 -.anchor before_xor - -.tp %1 -stp -.anchor bit_xor_buf_1 -.tp %2 -stp -.anchor bit_xor_buf_2 +; %4: CellBit tmp +%macro bit_raw_xor 4 +.anchor before_bit_raw_xor .tp %3 -set_0 -.tp bit_xor_buf_1 -set_0 -.tp bit_xor_buf_2 -set_0 +biz + flb +rnz + +.tp %4 +biz + flb +rnz + .tp %1 biz - .tp %2 - flb - .tp bit_xor_buf_1 - flb - .tp %1 - flb + .tp %3 + set_1 + .tp %1 + flb rnz + +.tp %3 +biz + .tp %1 + flb + .tp %2 + flb + .tp %4 + flb + .tp %3 + flb +rnz + .tp %2 biz - .tp %1 - flb - .tp %3 - flb - .tp bit_xor_buf_1 - flb - .tp %2 - flb + .tp %3 + flb + .tp %4 + flb + .tp %2 + flb rnz -.tp bit_xor_buf_1 + +.tp %4 biz - .tp %1 - flb - .tp %2 - flb - .tp bit_xor_buf_1 - flb + .tp %2 + set_1 + .tp %3 + set_1 + .tp %4 + flb rnz .tp before_xor @@ -104,15 +112,15 @@ rnz -; Macro xor +; Macro raw_xor ; %1: Unit arg1 ; %2: Unit arg2 ; %3: Cell ans -%macro xor 3 -.anchor before_xor +%macro raw_xor 4 +.anchor before_raw_xor %rep _CELL_SIZE - bit_xor %1 %2 %3 + bit_raw_xor %1 %2 %3 %4 .tp %1 ror .tp %2 @@ -120,5 +128,5 @@ rnz .tp %3 ror %endrep -.tp before_xor +.tp before_raw_xor %endmacro \ No newline at end of file diff --git a/asm/test.r8asm b/asm/test.r8asm index 4803bcd..6f3d1bb 100644 --- a/asm/test.r8asm +++ b/asm/test.r8asm @@ -1,11 +1,16 @@ -%include "asm/add.r8asm" -%include "asm/and.r8asm" +%include "asm/raw_add.r8asm" +%include "asm/raw_and.r8asm" +%include "asm/raw_or.r8asm" +%include "asm/raw_xor.r8asm" +%include "asm/raw_inc.r8asm" + .var A 0 .var B 2 .var Ci 4 .var S 6 .var Co 8 +.var tmp 1 .tp A .xor 126 @@ -14,23 +19,32 @@ .tp Ci .xor 1 -raw_add A B Ci S Co 1 +raw_add A B Ci S Co tmp -.tp A -out -.tp B -out -.tp Ci -out -.tp S -out -.tp Co -out +output A +output B +output Ci +output S +output Co -and A B S -.tp A -out -.tp B -out -.tp S -out \ No newline at end of file +raw_and A B S tmp +output A +output B +output S + +raw_or A B S tmp +output A +output B +output S + +raw_xor A B S tmp +output A +output B +output S + + +raw_inc A Ci S Co tmp +output A +output Ci +output S +output Co \ No newline at end of file