diff --git a/asm/and.r8asm b/asm/and.r8asm new file mode 100644 index 0000000..8ec7ccf --- /dev/null +++ b/asm/and.r8asm @@ -0,0 +1,54 @@ +; Macro unsafe_and +; %1: arg1 +; %2: arg2 +; %3: ans +%macro unsafe_and 3 +.anchor before_unsafe_and + +%repeat _UNIT_SIZE + .tp %3 + set_0 + .tp %1 + biz + .tp %2 + biz + .tp %3 + set_1 + .tp %2 + set_0 + rnz + .tp %1 + set_0 + rnz + + .tp %1 + ror + .tp %2 + ror + .tp %3 + ror +%endrepeat +.tp before_unsafe_and +%endmacro + + + + +; Macro and +; %1:unit1 +; %2:unit2 +; %3:ans_unit +%macro and 3 +.anchor before_and + +.tp %1 +copy_to_buffer %3 +stp ;Before r8asm_arg_stoi suppports evaluating,it's a compromise. +.anchor and_buf_1 ; +.tp %2 +copy_to_buffer %3 +stp ; +.anchor and_buf_2 ; +unsafe_and and_buf_1 and_buf_2 ans +.tp before_and +%endmacro \ No newline at end of file diff --git a/asm/asm.r8asm b/asm/asm.r8asm index 3972c05..1ac31e3 100644 --- a/asm/asm.r8asm +++ b/asm/asm.r8asm @@ -6,7 +6,9 @@ step 1 .anchor arg2 back 2 .anchor ans -and arg1 arg2 ans + +or arg1 arg2 ans + .tp arg1 out .tp arg2 diff --git a/asm/lib.r8asm b/asm/lib.r8asm index 9f8f479..132e9dc 100644 --- a/asm/lib.r8asm +++ b/asm/lib.r8asm @@ -74,59 +74,3 @@ ror .tp before_copy_to_buffer %endmacro - - - - -; Macro unsafe_and -; %1: arg1 -; %2: arg2 -; %3: ans -%macro unsafe_and 3 -.anchor before_unsafe_and - -%repeat _UNIT_SIZE - .tp %1 - biz - .tp %2 - biz - .tp %3 - set_1 - .tp %2 - set_0 - rnz - .tp %1 - set_0 - rnz - - .tp %1 - ror - .tp %2 - ror - .tp %3 - ror -%endrepeat -.tp before_unsafe_and -%endmacro - - - - -; Macro and -; %1:unit1 -; %2:unit2 -; %3:ans_unit -%macro and 3 -.anchor before_and - -.tp %1 -copy_to_buffer %3 -stp ;Before r8asm_arg_stoi suppports evaluating,it's a compromise. -.anchor and_buf_1 ; -.tp %2 -copy_to_buffer %3 -stp ; -.anchor and_buf_2 ; -unsafe_and and_buf_1 and_buf_2 ans -.tp before_and -%endmacro \ No newline at end of file diff --git a/asm/or.r8asm b/asm/or.r8asm new file mode 100644 index 0000000..9a1e940 --- /dev/null +++ b/asm/or.r8asm @@ -0,0 +1,56 @@ +; Macro unsafe_or +; %1: arg1 +; %2: arg2 +; %3: ans +%macro unsafe_or 3 +.anchor before_unsafe_or + +%repeat _UNIT_SIZE + .tp %3 + set_0 + .tp %1 + biz + .tp %3 + set_1 + .tp %1 + set_0 + rnz + .tp %2 + biz + .tp %3 + set_1 + .tp %2 + set_0 + rnz + + .tp %1 + ror + .tp %2 + ror + .tp %3 + ror +%endrepeat +.tp before_unsafe_or +%endmacro + + + + +; Macro or +; %1:unit1 +; %2:unit2 +; %3:ans_unit +%macro or 3 +.anchor before_or + +.tp %1 +copy_to_buffer %3 +stp ;Before r8asm_arg_stoi suppports evaluating,it's a compromise. +.anchor or_buf_1 ; +.tp %2 +copy_to_buffer %3 +stp ; +.anchor or_buf_2 ; +unsafe_or or_buf_1 or_buf_2 ans +.tp before_or +%endmacro \ No newline at end of file diff --git a/tests/r8_test.cc b/tests/r8_test.cc index 0387dd6..7ec9b18 100644 --- a/tests/r8_test.cc +++ b/tests/r8_test.cc @@ -5,11 +5,15 @@ int main(int argc, char *argv[]) { auto lib = read_src("asm/lib.r8asm"); + auto r8and = read_src("asm/and.r8asm"); + auto r8or = read_src("asm/or.r8asm"); /* for (auto i : lib.raw_src) for (auto j : i) std::cout << j << ';';*/ lib.preprocess(); + r8and.preprocess(); + r8or.preprocess(); auto src = read_src("asm/asm.r8asm"); auto out_tape = r8asm_tape_out(expand_macros(r8asm_preprocess(src))); for (auto i : out_tape)