|
@@ -5,16 +5,91 @@
|
|
|
struct opTableEntry{
|
|
|
enum op op;
|
|
|
const char* name;
|
|
|
-};
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
struct opTableEntry opTable[] = {
|
|
|
- {ADD, "add"},
|
|
|
- {SUB, "sub"},
|
|
|
- {MUL, "mul"},
|
|
|
- {DIV, "div"},
|
|
|
- {MOD, "mod"},
|
|
|
- {EQ, "eq"},
|
|
|
- {OPEND, NULL}
|
|
|
+ // OP_SP, OP_SSP, OP_BP, OP_SBP, OP_PC, OP_RV, OP_SRV,
|
|
|
+ {OP_SP, "sp"},
|
|
|
+ {OP_SSP, "ssp"},
|
|
|
+ {OP_BP, "bp"},
|
|
|
+ {OP_SBP, "sbp"},
|
|
|
+ {OP_PC, "pc"},
|
|
|
+ {OP_RV, "rv"},
|
|
|
+ {OP_SRV, "srv"},
|
|
|
+ // OP_IMM,
|
|
|
+ {OP_IMM, "imm"},
|
|
|
+ // OP_LD8, OP_LD16, OP_LD32, OP_LD,
|
|
|
+ {OP_LD8, "ld8"},
|
|
|
+ {OP_LD16, "ld16"},
|
|
|
+ {OP_LD32, "ld32"},
|
|
|
+ {OP_LD, "ld"},
|
|
|
+ // OP_ST8, OP_ST16, OP_ST32, OP_ST,
|
|
|
+ {OP_ST8, "st8"},
|
|
|
+ {OP_ST16, "st16"},
|
|
|
+ {OP_ST32, "st32"},
|
|
|
+ {OP_ST, "st"},
|
|
|
+ // OP_DUP, OP_POP, OP_SWAP, OP_OVER, OP_ROT,
|
|
|
+ {OP_DUP, "dup"},
|
|
|
+ {OP_POP, "pop"},
|
|
|
+ {OP_SWAP, "swap"},
|
|
|
+ {OP_OVER, "over"},
|
|
|
+ {OP_ROT, "rot"},
|
|
|
+ // OP_ADD, OP_SUB, OP_DIV, OP_MUL, OP_MOD,
|
|
|
+ {OP_ADD, "add"},
|
|
|
+ {OP_SUB, "sub"},
|
|
|
+ {OP_DIV, "div"},
|
|
|
+ {OP_MUL, "mul"},
|
|
|
+ {OP_MOD, "mod"},
|
|
|
+ // OP_SHR, OP_SHL, OP_SAR,
|
|
|
+ {OP_SHR, "shr"},
|
|
|
+ {OP_SHL, "shl"},
|
|
|
+ {OP_SAR, "sar"},
|
|
|
+ // OP_AND, OP_OR, OP_NOT,
|
|
|
+ {OP_AND, "and"},
|
|
|
+ {OP_OR, "or"},
|
|
|
+ {OP_NOT, "not"},
|
|
|
+ // OP_BITAND, OP_BITOR, OP_XOR, OP_INVERT,
|
|
|
+ {OP_BITAND, "bitand"},
|
|
|
+ {OP_BITOR, "bitor"},
|
|
|
+ {OP_XOR, "xor"},
|
|
|
+ {OP_INVERT, "invert"},
|
|
|
+ // OP_GT, OP_LT, OP_GE, OP_LE, OP_EQ, OP_NEQ,
|
|
|
+ {OP_GT, "gt"},
|
|
|
+ {OP_LT, "lt"},
|
|
|
+ {OP_GE, "ge"},
|
|
|
+ {OP_LE, "le"},
|
|
|
+ {OP_EQ, "eq"},
|
|
|
+ {OP_NEQ, "neq"},
|
|
|
+ // OP_JMP, OP_JZ, OP_JNZ, OP_RET, OP_CALL, OP_SYSCALL,
|
|
|
+ {OP_JMP, "jmp"},
|
|
|
+ {OP_JZ, "jz"},
|
|
|
+ {OP_JNZ, "jnz"},
|
|
|
+ {OP_RET, "ret"},
|
|
|
+ {OP_CALL, "call"},
|
|
|
+ {OP_SYSCALL, "syscall"},
|
|
|
+ // OP_FADD, OP_FSUB, OP_FMUL, OP_FDIV,
|
|
|
+ {OP_FADD, "fadd"},
|
|
|
+ {OP_FSUB, "fsub"},
|
|
|
+ {OP_FMUL, "fmul"},
|
|
|
+ {OP_FDIV, "fdiv"},
|
|
|
+ // OP_FGE, OP_FGT, OP_FLE, OP_FLT, OP_FEQ, OP_FNEQ,
|
|
|
+ {OP_FGE, "fge"},
|
|
|
+ {OP_FGT, "fgt"},
|
|
|
+ {OP_FLT, "flt"},
|
|
|
+ {OP_FEQ, "feq"},
|
|
|
+ {OP_FNEQ, "fneq"},
|
|
|
+ // OP_FTI, OP_ITF,
|
|
|
+ {OP_FTI, "fti"},
|
|
|
+ {OP_ITF, "itf"},
|
|
|
+ // OP_EXIT,
|
|
|
+ {OP_EXIT, "exit"},
|
|
|
+ // OP_LDARG, OP_LDVAR, OP_STARG, OP_STVAR,
|
|
|
+ {OP_LDARG, "ldarg"},
|
|
|
+ {OP_LDVAR, "ldvar"},
|
|
|
+ {OP_STARG, "starg"},
|
|
|
+ {OP_STVAR, "stvar"},
|
|
|
+ {OP_END, NULL},
|
|
|
};
|
|
|
|
|
|
enum op str2op(const char* str) {
|
|
@@ -23,5 +98,9 @@ enum op str2op(const char* str) {
|
|
|
return opTable[i].op;
|
|
|
}
|
|
|
}
|
|
|
- return OPEND;
|
|
|
+ return OP_END;
|
|
|
+}
|
|
|
+
|
|
|
+int isOp(const char *str) {
|
|
|
+ return OP_END != str2op(str);
|
|
|
}
|