x86: fix issue #214

This commit is contained in:
Nguyen Anh Quynh
2016-07-02 03:06:09 +08:00
parent ce922a6414
commit 2b0fc2eeaa
2 changed files with 13 additions and 7 deletions
@@ -167,7 +167,7 @@ private:
InfixOperatorStack.push_back(Op);
}
int64_t execute(unsigned int &KsError) { // qq
int64_t execute(unsigned int &KsError) {
// Push any remaining operators onto the postfix stack.
while (!InfixOperatorStack.empty()) {
InfixCalculatorTok StackOp = InfixOperatorStack.pop_back_val();
@@ -2584,8 +2584,14 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
Parser.eatToEndOfStatement();
return true;
}
// check for comma and eat it
if (getLexer().is(AsmToken::Comma))
// for LJMP, check for ':'. otherwise, check for comma and eat it
if (Name.startswith("ljmp") || Name.startswith("ljmp")) {
if (getLexer().is(AsmToken::Colon)) {
//Parser.Lex();
Operands.push_back(X86Operand::CreateToken(":", consumeToken()));
} else
break;
} else if (getLexer().is(AsmToken::Comma))
Parser.Lex();
else
break;
+4 -4
View File
@@ -1,6 +1,6 @@
#!/usr/bin/python
# Test if "jmp 0x33, 08" throws an error.
# Test if "ljmp 0x33:08" throws an error.
# Github issue: #214
# Author: Duncan (mrexodia)
@@ -15,10 +15,10 @@ class TestX86Intel(regress.RegressTest):
ks = Ks(KS_ARCH_X86, KS_MODE_32)
# Assemble with zero addr
try:
encoding, count = ks.asm("jmp 0x33, 08", 0)
self.fail()
encoding, count = ks.asm("ljmp 0x33:08", 0)
self.assertEqual(encoding, [ 0xea, 0x08, 0x00, 0x30, 0x00 ])
except KsError as e:
pass
if __name__ == '__main__':
regress.main()
regress.main()