From 3a5df2cbefe6d0826e7f851fa7552b08ab5c978d Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 11 Aug 2018 10:33:26 -0700 Subject: 4503 --- subx/031check_operands.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'subx/031check_operands.cc') diff --git a/subx/031check_operands.cc b/subx/031check_operands.cc index 6afab0a6..1e840a81 100644 --- a/subx/031check_operands.cc +++ b/subx/031check_operands.cc @@ -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. -- cgit 1.4.1-2-gfad0