Github repository

cmpdism is a special command line–based disassembler that can compare two binaries for altered code. Given two binary files, it disassembles them and prints special markers indicating which instructions have been added, removed, or changed. What makes it useful is that it can ignore changes that result solely from reassembling/recompiling, e.g. altered code offsets, and spot out only the actual changes. This was originally created to aid in the development of the Un-Worked Designs patches (especially Magic Knight Rayearth).

Additionally, the program provides a generic framework for this comparative disassembly task, allowing modules for new instruction sets to be added to the program with minimal work. Currently, the following architectures are supported:

  • 6502 family:
    • MOS Technologies 6502 (NES, C64, many others)
    • WDC 65C02
    • Hudson HuC6280 (PC Engine)
  • 68000 family:
    • Motorola 68000 (Mega Drive, many others)
  • SH family:
    • Hitachi SH-2 (Saturn, 32X)
  • Z80 family:
    • Zilog Z80 (Master System, Game Gear, uncountable others)
    • Sharp LR35902 (Game Boy)
  • Multi-processor instruction sets:
    • MIPS-I (PlayStation) – coprocessor instructions currently unsupported
  • Additionally, the program can do a raw byte-to-byte comparison between two files, like the Unix cmp utility.

Warning: This program consumes tremendous amounts of memory. This is partly due to the fact that I wrote it in C instead of C++ as an experiment (discovering why vtables exist in the process), but mostly due to lazy program design (the input files are disassembled entirely before processing them, instead of disassembling only the "window" needed for comparison). I'd suggest not feeding it more than a megabyte or so at a time unless your system is well equipped.