keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Wrong disassembly with inline comments in assembly

Open brendabrandy opened this issue 6 years ago • 4 comments

When I use kstool to assemble the following instruction with a comment, I got an error:

$ kstool arm64 "MOV X29, SP ;hello"
ERROR: failed on ks_asm() with count = 0, error = 'Invalid mnemonic (KS_ERR_ASM_MNEMONICFAIL)' (code = 514)

but it worked properly without a comment:

$ kstool arm64 "MOV X29, SP"
MOV X29, SP = [ fd 03 00 91 ]

Is there an expected syntax for commenting for keystone, or keystone cannot differentiate between comments and operands of an instruction? If so, I'd like to submit a patch to support inline comments.

brendabrandy avatar Jan 29 '19 20:01 brendabrandy

If you take a look at the C example on http://www.keystone-engine.org/ towards the bottom you'll see it mention You can either separate assembly instructions in this string by “;” or “\n”. so I believe this is the intended behavior. I'm not a project member but I agree a patch to enable comments with a semicolon would be pretty useful.

zeroSteiner avatar Feb 06 '19 16:02 zeroSteiner

@zeroSteiner commented on Feb 6, 2019:

I agree a patch to enable comments with a semicolon would be pretty useful.

+1

sskras avatar Sep 29 '22 08:09 sskras