From 53cbf0ccc361f60394e6ec084479265755b44f9b Mon Sep 17 00:00:00 2001 From: StarCells Date: Wed, 26 Aug 2026 00:22:37 +0800 Subject: [PATCH] 202608260022 --- include/r8asm/r8asm.hh | 34 ++++++++++++++++++++-------------- src/r8asm.cc | 6 +++--- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/r8asm/r8asm.hh b/include/r8asm/r8asm.hh index a95ee46..f6e7760 100644 --- a/include/r8asm/r8asm.hh +++ b/include/r8asm/r8asm.hh @@ -55,9 +55,11 @@ public: NEG, }; std::map operator_map = { - {"+", operator_t::ADD}, {"-", operator_t::SUB}, {"*", operator_t::MUL}, - {"/", operator_t::DIV}, {"^", operator_t::XOR}, {"&", operator_t::AND}, - {"|", operator_t::OR}, {"~", operator_t::NOT}}; + {"op_add", operator_t::ADD}, {"op_sub", operator_t::SUB}, + {"op_mul", operator_t::MUL}, {"op_div", operator_t::DIV}, + {"op_xor", operator_t::XOR}, {"op_and", operator_t::AND}, + {"op_or", operator_t::OR}, {"op_not", operator_t::NOT}, + {"op_neg", operator_t::NEG}}; enum class builtin_t { ANCHOR, TP, @@ -67,9 +69,12 @@ public: VAR, }; std::map builtin_map = { - {"anchor", builtin_t::ANCHOR}, {"tp", builtin_t::TP}, - {"xor", builtin_t::XOR}, {"loop", builtin_t::LOOP}, - {"endloop", builtin_t::ENDLOOP}, {"var", builtin_t::VAR}, + {"builtin_anchor", builtin_t::ANCHOR}, + {"builtin_tp", builtin_t::TP}, + {"builtin_xor", builtin_t::XOR}, + {"builtin_loop", builtin_t::LOOP}, + {"builtin_endloop", builtin_t::ENDLOOP}, + {"builtin_var", builtin_t::VAR}, }; enum class rot8_t { STP, // Step Tape Pointer,'>' @@ -82,9 +87,10 @@ public: INP, // INPut byte,',' }; std::map rot8_map = { - {"stp", rot8_t::STP}, {"btp", rot8_t::BTP}, {"ror", rot8_t::ROR}, - {"flb", rot8_t::FLB}, {"biz", rot8_t::BIZ}, {"rnz", rot8_t::RNZ}, - {"out", rot8_t::OUT}, {"inp", rot8_t::INP}, + {"rot8_stp", rot8_t::STP}, {"rot8_btp", rot8_t::BTP}, + {"rot8_ror", rot8_t::ROR}, {"rot8_flb", rot8_t::FLB}, + {"rot8_biz", rot8_t::BIZ}, {"rot8_rnz", rot8_t::RNZ}, + {"rot8_out", rot8_t::OUT}, {"rot8_inp", rot8_t::INP}, }; general_data read_parameter(std::string index_str); }; @@ -96,9 +102,9 @@ public: INCLUDE, }; std::map directive_map = { - {"macro", r8asm::directive_t::MACRO}, - {"endmacro", r8asm::directive_t::ENDMACRO}, - {"rep", r8asm::directive_t::REP}, - {"endrep", r8asm::directive_t::ENDREP}, - {"include", r8asm::directive_t::INCLUDE}}; + {"dir_macro", r8asm::directive_t::MACRO}, + {"dir_endmacro", r8asm::directive_t::ENDMACRO}, + {"dir_rep", r8asm::directive_t::REP}, + {"dir_endrep", r8asm::directive_t::ENDREP}, + {"dir_include", r8asm::directive_t::INCLUDE}}; }; \ No newline at end of file diff --git a/src/r8asm.cc b/src/r8asm.cc index 3331bdf..004b594 100644 --- a/src/r8asm.cc +++ b/src/r8asm.cc @@ -75,7 +75,7 @@ r8asm::general_data r8asm::ast::read_parameter(std::string index_str) { // TODO: FILL THE BLANK #define ROT8_NODE(INS) \ { \ - r8asm::ast_node_t::ROT8, INS, {} \ + r8asm::ast_node_t::ROT8, std::string("rot8_") + INS, {} \ } std::vector r8asm::ast::expand_node_to_ins(const ast_node &node) { @@ -171,8 +171,8 @@ r8asm::ast::expand_node_to_ins(const ast_node &node) { data d = expand_node_to_data(node.children[0]); for (auto i = 0; i < CELL_SIZE; i++) { if (d & 1) - to_return.push_back(ROT8_NODE("FLB")); - to_return.push_back(ROT8_NODE("ROR")); + to_return.push_back(ROT8_NODE("flb")); + to_return.push_back(ROT8_NODE("ror")); d >>= 1; } } break;