This commit is contained in:
starcells committed 2026-06-12 08:29:05 +08:00
1 parent cde17c9506
commit 54979833dc
5 files changed
+117 -57

No files matched your search

+54
View File
@@ -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
+3 -1
View File
@@ -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
-56
View File
@@ -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
+56
View File
@@ -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
+4
View File
@@ -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)