keystone icon indicating copy to clipboard operation
keystone copied to clipboard

pushw imm

Open fvrmatteo opened this issue 9 years ago • 5 comments

Wrong output for: "push word 0x1122". Expected: "66 68 22 11". Kstool output: "68 22 11 00 00". I then tried with: "pushw 0x1122". Excepted: "66 68 22 11". Kstool output: KS_ERR_ASM_MNEMONICFAIL.

If the mnemonic "pushw" is not going to be supported, I think parsing correctly the size specification, like "word" in "push word 0x1122" is the fix. It all depends on the first byte 0x66.

fvrmatteo avatar Jun 27 '16 13:06 fvrmatteo

see related issue https://github.com/keystone-engine/keystone/issues/10. it seems the fix for it is just partially correct.

can you send a PR to add your case to x86_issue10.py ?

pushw is an invalid mnemonic

aquynh avatar Jun 27 '16 14:06 aquynh

Maybe I'm wrong but the only file modified to "fix" it is the regress test "x86_issue10.py" and it fails.

I have this commit : commit 95b7212a8514dff1861245300857accec34a120f (HEAD -> master, origin/master, origin/HEAD)

And this is the result of regress.py :

Ran 77 tests in 0.069s FAILED (failures=7, errors=1)

This is for x86_issue10.py :

FAIL: runTest (main.TestX86)

Traceback (most recent call last): File "./x86_issue10.py", line 23, in runTest self.assertEqual(encoding3, [ 0x66, 0x68, 0x34, 0x12 ]) AssertionError: Lists differ: [104, 52, 18, 0, 0] != [102, 104, 52, 18]

First differing element 0: 104 102

First list contains 1 additional elements. First extra element 4: 0

-[104, 52, 18, 0, 0] +[102, 104, 52, 18]

Summus-31c04089c3cd80 avatar Sep 20 '17 10:09 Summus-31c04089c3cd80

Up

Summus-31c04089c3cd80 avatar Apr 13 '18 15:04 Summus-31c04089c3cd80

I've also encountered the issue on my side.

I'm using the latest keystone engine bindings in a python script to compile 32 bit assembly.

The issue can also be reproduced with this keystone engine online demo : https://alexaltea.github.io/keystone.js/

For example compiling the following assembly : push word 0x1234;

gives the following ouput : 68 34 12 00 00

but it should be : 66 68 34 12

Let me know if you guys need help for this issue.

Best regards

Recurse-blip avatar Dec 08 '20 00:12 Recurse-blip