www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - disasmarm.d now can be a standalone program

reply Walter Bright <newshound2 digitalmars.com> writes:
I've been using godbolt.org to figure out which #AArch64 instructions are 
generated for which operations, as I find the instruction descriptions are 
frequently baffling.

But I've been reduced to taking the godbolt 8 bit hex instructions and compare 
them against the 2000 #AArch64 instructions to get a match (yes, the mnemonic 
helps a lot, but as many mnemonics have multiple encodings, it's back to 
tedium). It's laborious because the instruction encodings do not line up on
byte 
boundaries, so I have to convert it to binary and then mark out the bit fields 
by hand (dammit D needs bit fields!)

I finally realized disasmarm.d can help. I fixed it so one just types in the 8 
hex bytes on the command for the instruction, and it will disassemble it and 
provide the correct URL to the manual page for that instruction.

disasmarm.d can be compiled with:

```
dmd disasmarm.d -version=StandAlone
```

to make a standalone program and it will do a little disassembling:

```
./disasmarm fd401bff

https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldst_pos
```

It's incomplete as it doesn't yet handle all the encodings, but I work on it as 
needed.
Sep 04
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 05/09/2024 4:17 PM, Walter Bright wrote:
 I've been using godbolt.org to figure out which #AArch64 instructions 
 are generated for which operations, as I find the instruction 
 descriptions are frequently baffling.
 
 But I've been reduced to taking the godbolt 8 bit hex instructions and 
 compare them against the 2000 #AArch64 instructions to get a match (yes, 
 the mnemonic helps a lot, but as many mnemonics have multiple encodings, 
 it's back to tedium). It's laborious because the instruction encodings 
 do not line up on byte boundaries, so I have to convert it to binary and 
 then mark out the bit fields by hand (dammit D needs bit fields!)
 
 I finally realized disasmarm.d can help. I fixed it so one just types in 
 the 8 hex bytes on the command for the instruction, and it will 
 disassemble it and provide the correct URL to the manual page for that 
 instruction.
 
 disasmarm.d can be compiled with:
 
 ```
 dmd disasmarm.d -version=StandAlone
 ```
 
 to make a standalone program and it will do a little disassembling:
 
 ```
 ./disasmarm fd401bff

 https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#ldst_pos
 ```
 
 It's incomplete as it doesn't yet handle all the encodings, but I work 
 on it as needed.
At this rate we'll have our own objdump before a years end! (Year unspecified)
Sep 04
parent Walter Bright <newshound2 digitalmars.com> writes:
On 9/4/2024 10:31 PM, Richard (Rikki) Andrew Cattermole wrote:
 At this rate we'll have our own objdump before a years end! (Year unspecified)
We already have obj2asm, which does the same thing as objdump, and incorporates disasmarm. obj2asm already decodes ARM object files. But objdump/obj2asm work off of .o files, which are not useful for looking at individual encodings, and don't provide a URL for the spec.
Sep 05