202608260022
This commit is contained in:
1 parent
18073acd2c
commit
53cbf0ccc3
2 files changed
+23
-17
No files matched your search
+20
-14
@@ -55,9 +55,11 @@ public:
|
||||
NEG,
|
||||
};
|
||||
std::map<std::string, operator_t> 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<std::string, builtin_t> 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<std::string, rot8_t> 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<std::string, directive_t> 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}};
|
||||
};
|
||||
+3
-3
@@ -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_node>
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user