diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-08-11 10:33:26 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-08-11 10:33:26 -0700 |
commit | 3a5df2cbefe6d0826e7f851fa7552b08ab5c978d (patch) | |
tree | 8691710ee2a0fd44086e44c3579114127a334d75 /subx | |
parent | 0e9b21dcc80075537e8379a09bb21d9e8b6a31e6 (diff) | |
download | mu-3a5df2cbefe6d0826e7f851fa7552b08ab5c978d.tar.gz |
4503
Diffstat (limited to 'subx')
-rw-r--r-- | subx/031check_operands.cc | 9 |
1 files changed, 9 insertions, 0 deletions
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. |