Fixed copy_to_buffer.

This commit is contained in:
starcells committed 2026-05-31 16:07:45 +08:00
1 parent 9cab4f4ee0
commit 12d66b37d3
4 files changed
+35 -18

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
.xor 13
copy_to_buffer 1
copy_to_buffer 3
out
stp
out
out
+30 -11
View File
@@ -1,31 +1,33 @@
;lib.r8asm
%macro step 1
stp %1
stp %1
%endmacro
%macro back 1
btp %1
btp %1
%endmacro
%macro set_0 0
biz
flb
rnz
%endmacro
%macro set_1 0
set_0
flb
%endmacro
%macro erase 0
%repeat _UNIT_SIZE
set_0
ror
%endrepeat
%endmacro
; Macro copy_to_buffer.
@@ -35,8 +37,12 @@ flb
;TODO
%macro copy_to_buffer 1
.anchor before_copy_to_buffer
stp
erase
.tp %1
erase
.tp before_copy_to_buffer
%repeat _UNIT_SIZE
biz
stp
@@ -46,6 +52,13 @@ biz
.tp before_copy_to_buffer
flb
rnz
.tp before_copy_to_buffer
ror
stp
ror
.tp %1
ror
.tp before_copy_to_buffer
%endrepeat
.tp %1
@@ -56,6 +69,11 @@ biz
.tp %1
flb
rnz
.tp before_copy_to_buffer
ror
.tp %1
ror
.tp %1
%endrepeat
.tp before_copy_to_buffer
@@ -63,13 +81,14 @@ rnz
; Macro and
; Macro unsafe_and
; %1: arg1
; %2: arg2
; %3: ans
;TODO
%macro and 3
.anchor before_and
%macro unsafe_and 3
.anchor before_unsafe_and
%repeat _UNIT_SIZE
.tp %1
@@ -92,7 +111,7 @@ rnz
.tp %3
ror
%endrepeat
.tp before_and
.tp before_unsafe_and
%endmacro
+2 -4
View File
@@ -63,6 +63,7 @@ void expand_anchor(std::vector<rot8_bytecode> &tape, R8Operand arg) {
datas.insert({std::to_string(*name), dataptr});
}
/*
void expand_erase(std::vector<rot8_bytecode> &tape, R8Operand arg) {
std::vector<rot8_bytecode> tmp = {rot8_bytecode::BIZ, rot8_bytecode::FLB,
rot8_bytecode::RNZ,
@@ -70,7 +71,7 @@ void expand_erase(std::vector<rot8_bytecode> &tape, R8Operand arg) {
for (unit_size_type i = 0; i < UNIT_SIZE; i++)
tape.insert(tape.end(), tmp.begin(), tmp.end());
return;
}
}*/
void expand_bytecode(std::vector<rot8_bytecode> &tape, R8Operand arg,
rot8_bytecode op, bool count_offset = true) {
@@ -108,9 +109,6 @@ std::vector<rot8_bytecode> r8asm_tape_out(std::span<const R8Instruction> ops) {
break;
case r8asm_builtin::ANCHOR:
expand_anchor(tape, it.formal_para);
case r8asm_builtin::ERASE:
break;
expand_erase(tape, it.formal_para);
break;
default:;
}
+1 -1
View File
@@ -14,5 +14,5 @@ std::map<std::string, R8MetaOp> r8asm_insmap = {
{"out", rot8_bytecode::OUT}, {"inp", rot8_bytecode::INP},
{".loop", r8asm_builtin::LOOP}, {".endloop", r8asm_builtin::ENDLOOP},
{".anchor", r8asm_builtin::ANCHOR}, {".tp", r8asm_builtin::TP},
{".xor", r8asm_builtin::XOR}, {".erase", r8asm_builtin::ERASE},
{".xor", r8asm_builtin::XOR},
};