NeatMonster / AMIE

A Minimalist Instruction Extender for the ARM architecture and IDA Pro
MIT License
193 stars 24 forks source link

Share you parser script #3

Closed dummys closed 4 years ago

dummys commented 5 years ago

Hello,

Is it possible to share your parser script ? Thanks

NeatMonster commented 5 years ago

Hello @dummys,

I should probably have acknowledged your issue sooner.


Regarding your original request:

The documentation is missing for Thumb2 instruction, like NEGS and NEGPL.

By greping into the *.json files:

>>> grep -rni "NEGS" *.json
aarch64.json:2082:      "NEGS_SUBS_addsub_shift": {
aarch64.json:2084:        "heading": "NEGS",
aarch64.json:2087:            "NEGS  <Wd>, <Wm>{, <shift> #<amount>}",
aarch64.json:2088:            "NEGS  <Xd>, <Xm>{, <shift> #<amount>}"
aarch64.json:4979:        "NEGS_SUBS_addsub_shift": {

we can see that documentation is there.

Let's double-check the instruction's encoding:

aarch64.json:4979:        "NEGS_SUBS_addsub_shift": {
aarch64.json-4980-          "S": ["x1101011xx0xxxxxxxxxxx11111xxxxx"]
aarch64.json-4981-        },

from the ARM documentation, section C6.2.293 SUBS (shifted register), we see that: 2018-12-11-132159_764x110_scrot

and

Alias is preferred when CMP (shifted register) Rd == '11111' NEGS Rn == '11111'

So it looks like a match to me.

Next up, let's assemble the instruction with Capstone (e.g. using this Online Assembler and Disassembler). Encoding NEGS X0, X1 yields E0 03 01 EB. I then used the Edit > Patch program > Patch bytes... function from IDA to insert it into an existing database. Finally, this is what I see: 2018-12-11-133812_1900x1026_scrot

You mentioned Thumb2 instruction, but according to the link in your second edit, this instruction is part of the A64 General Instructions. Do you have a concrete example that you can share with me?


Regarding your second request, I don't mind sharing the parser script, but definitively not on this repository. They're really messy and I don't feel I'll ever be able to clean them up (and there will probably never be a need to do so). I feel that maybe an appropriate place would be in a Gist.

For the last week I've been working on parsing the Cortex-specific documentation to add support for the implementation-defined registers, something that I want to finish before thinking about releasing the parsing scripts. You may rest assured that this project is still active, even though releasing update takes a long time.

You can also edit the data files manually and submit pull requests if you feel like it.

dummys commented 5 years ago

Yes you are right, I was false on the thumb2 thingy. First of all I would like to thank you for the greate works. Really appreciated. For the NEGPL, I think it's a pseudo instruction made by Ida, I need to validate this.

NeatMonster commented 4 years ago

I've updated the JSON files to "Armv8.6-A 2019-09 (bet)".

Here is the parsing script: https://dl.neat.sh/ARMExplorer.zip