This commit is contained in:
starcells committed 2026-06-10 20:58:41 +08:00
1 parent 9be37cc460
commit d33f0aefe7
5 files changed
+36 -25

No files matched your search

+12 -2
View File
@@ -1,5 +1,15 @@
step 3
.xor 13
copy_to_buffer 3
.anchor arg1
step 1
.xor 7
.anchor arg2
back 2
.anchor ans
and arg1 arg2 ans
.tp arg1
out
stp
.tp arg2
out
.tp ans
out
+18 -18
View File
@@ -32,9 +32,6 @@ ror
; Macro copy_to_buffer.
; %1: tmp
;move(0,{0',1'})
;move(1',0)
;TODO
%macro copy_to_buffer 1
.anchor before_copy_to_buffer
@@ -86,7 +83,6 @@ ror
; %1: arg1
; %2: arg2
; %3: ans
;TODO
%macro unsafe_and 3
.anchor before_unsafe_and
@@ -116,18 +112,22 @@ ror
; Macro or
; %1: arg1
; %2: arg2
; %3: ans
;TODO
%macro or 3
.anchor before_or
%repeat _UNIT_SIZE
.tp %1
biz
rnz
%endrepeat
.tp before_or
%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
+2 -2
View File
@@ -58,9 +58,9 @@ void expand_tp(std::vector<rot8_bytecode> &tape, R8Operand arg,
void expand_anchor(std::vector<rot8_bytecode> &tape, R8Operand arg) {
if (const std::string *name = std::get_if<std::string>(&arg))
datas.insert({*name, dataptr});
datas.insert_or_assign(*name, dataptr);
else if (const r8asm_data *name = std::get_if<r8asm_data>(&arg))
datas.insert({std::to_string(*name), dataptr});
datas.insert_or_assign(std::to_string(*name), dataptr);
}
/*
+3 -3
View File
@@ -17,7 +17,7 @@ std::map<std::string, R8MetaOp> r8asm_parsemap = {
{"%endrepeat", r8asm_builtin::ENDREPEAT},
};
void r8asm_trim(std::string &str) {
void r8asm_trim(std::string &str) { // Clean empty chars in the string.
auto start = str.find_first_not_of(EMPTY_CHARS);
if (!(start ==
@@ -28,7 +28,7 @@ void r8asm_trim(std::string &str) {
str = "";
}
std::string r8asm_peel(std::string &str) {
std::string r8asm_peel(std::string &str) { // Peel a word from string.
r8asm_trim(str);
auto end = str.find_first_of(EMPTY_CHARS);
@@ -76,7 +76,7 @@ R8Src read_src(std::string filename) {
return (src);
}
R8Operand r8asm_arg_stoi(std::string raw_arg) {
R8Operand r8asm_arg_stoi(std::string raw_arg) { // TODO:expression evaluating
try {
r8asm_data arg = std::stoi(raw_arg);
return (arg);
+1
View File
@@ -14,5 +14,6 @@ int main(int argc, char *argv[]) {
auto out_tape = r8asm_tape_out(expand_macros(r8asm_preprocess(src)));
for (auto i : out_tape)
std::cout << ROT8_BC_TO_CHAR(i);
std::cout << std::endl;
return (0);
}