DigicoolThings / HxD_DasmDataInspectorPlugin

A generic Disassembly Plugin for Maël Hörz's HxD Freeware Hex Editor and Disk Editor.
Apache License 2.0
45 stars 6 forks source link

Disassembly Plugin for HxD's Data inspector

This plugin is for Maël Hörz's excellant HxD hex and disk editor, which is available at: http://mh-nexus.de/hxd

This plugin is compiled for HxD v2.5.0.0

Background

I came across HxD while looking for a good hex editor, to allow visually comparing & analysing the differences between some retro Motorola MC6809 Monitor ROM images.

I was immediately impressed that Maël had included support for Motorola S-record files, and when I noticed the Data inspector included x86 Disassembly I immediately thought how useful 6809 Disassembly would be. As I was seeing byte differences in my 6809 ROM comparisons, I was having to manually identify what the code differences were.

I initially looked for a pre-written Disassembler that I could integrate via Maël's published plugin framework: https://github.com/maelh/hxd-plugin-framework

But I quickly came to the conclusion that there wasn't really anything substantial that I could (relatively easily) migrate for this purpose. Plus, with my retro CPU interests, I could see that I'd potentially want to also add 6800 and 6502 code disassembly (ed. which I have now done), and maybe even 68000, and looking at existing disassemblers, I really didn't like the "hard-coded" processor specific parsing approach.

Implementation

To allow support for different CPU instruction Disassembly, I decided to implement a generic Disassembly plugin, that would allow additional CPU's to be supported by dropping-in new CPU definition files.

In other words, create a Disassembly plugin that anyone could add support for another CPU, without needing to write a whole new instruction disassembler / without having to make any code changes.

To achieve this, the plugin .dll (DasmDataInspectorPlugin.dll) references a .ini file (DasmDataInspectorPlugin.ini) for parameters, including details of the configured CPU's / Disassembly types. For each configured CPU, a .csv based instruction definition file is also included.

To get started, I initially created a Motorola MC6800 definition file as: Dasm6800.csv I've now also added several other processor definition files including 6502 family etc. (refer below), and also the more complex MC6809 8/16 bit processor definition file.

To assist with debugging your own definition .csv files (or any changes you might want to make), the .ini file provides for a log file to be enabled. This provides visibility of the .csv file parsing and format errors (typos?) that are identified.

Note that while this implementation provides great flexibility for adding additional CPU Disassembly support, it's target audience is retro microprocessors. These generally have relatively simple instruction sets and addressing modes, which the definition files easily cater for. However, I suspect limitation may be found if attempting to define more advanced / modern ISA's. Specifically, where a CPU has a significantly more complex instruction set, resulting in an excessively large number of resulting possible opcode + operand combinations.

Installation

Firstly, ensure you are running HxD 2.5.0.0 version. This plugin is currently compiled for 2.5.0.0. If a later HxD version requires changes to the plug-in interface, I will update the plugin here (as required).

As per Maël's instructions for the plugin framework, the files should all be installed into a "Plugins" sub-directory of your HxD installation directory.

First select either the Win64 or Win32 folder .dll version (based on your Windows installation), and copy the content of this folder into your HxD installation directory, creating (or updating) the "Plugins" sub-directory of your HxD installation directory.

Then also copy the contents of the Common folder, which contains the DasmDataInspectorPlugin.ini and the various CPU definition .csv files (once again, in the "Plugins" sub-directory).

Finally (optional - but recommended!), you can edit the DasmDataInspectorPlugin.ini file to include only the specific DasmTypes that you currently require or are interest in. As per the documented .ini file, you can have up to 8 different Disassembly types at a time, however each one adds some HxD start-up time overhead as the definition files are loaded and parsed. Therefore, depending on your system performance, you may not wish to load all (or multiple) DasmTypes.

Configuration

Further to the above note on DasmTypes, please refer to the .ini file for documentation on the various settings included. Hopefully this should all be self explanatory.

The .csv definition files (configured and referenced from the .ini file), have relatively self explanatory column titles in the header line. Note this header line is purely optional, and is just included for readability / reference. Leaving the header line in place has no impact on load time.

CSV file column descriptions

Reviewing the above, in combination with the various included (completed) .csv files, should help clarify the definition file structure.

Features

CPU ISA's currently defined (Complete), or in progress (Incomplete)

All the Complete definitions have been carefully checked, however if you identify any coding errors please raise an issue or cummunicate with the contributer, so these can be corrected.

Of Note:

Source

The fully commented source code is available in the src folder (for those interested). Note that the source code is not required for using this HxD DataInsepctor Plugin (the required compiled .dll is in the Win64 or Win32 folder), nor is it required for adding your own .csv CPU definitions (if you do create an additional CPU defintion file, please share it!).

The source code was compiled with Delphi 10.3 Community Edition. The Community Edition is available free for non-profit use, however please refer to the Embarcadero website for their full license terms and to obtain the Delphi IDE.

License

HxD Plugin Framework is Copyright (C) 2019-2021 Maël Hörz. The plugin framework is licensed under the MPL.

This Disassembly Plugin is Copyright (C) 2021 DigicoolThings (Digicool Things), and distributed as per the MPL Larger Work definition and licensed under the Apache License 2.0

Contact

For bugs and CPU definition discussion, please use the issue tracker on GitHub.

There is also discussion on the forum: https://forum.mh-nexus.de