diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index cd320a2..457e26d 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -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; diff --git a/suite/regress/x86_jmp_0x33_08.py b/suite/regress/x86_jmp_0x33_08.py index 7fc4ea6..05b12b4 100755 --- a/suite/regress/x86_jmp_0x33_08.py +++ b/suite/regress/x86_jmp_0x33_08.py @@ -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() \ No newline at end of file + regress.main()