This commit is contained in:
Kartik Agaram 2018-08-11 10:33:26 -07:00
parent 0e9b21dcc8
commit 3a5df2cbef
1 changed files with 9 additions and 0 deletions

View File

@ -38,11 +38,20 @@ void check_operands(const line& inst) {
word preprocess_op(word/*copy*/ op) {
op.data = tolower(op.data.c_str());
// opcodes can't be negative
if (starts_with(op.data, "0x"))
op.data = op.data.substr(2);
if (SIZE(op.data) == 1)
op.data = string("0")+op.data;
return op;
}
void test_preprocess_op() {
word w1; w1.data = "0xf";
word w2; w2.data = "0f";
CHECK_EQ(preprocess_op(w1).data, preprocess_op(w2).data);
}
//: To check the operands for an opcode, we'll track the permitted operands
//: for each supported opcode in a bitvector. That way we can often compute the
//: bitvector for each instruction's operands and compare it with the expected.