One embodiment of the present invention provides a system that facilitates implementing
multi-mode specification-driven disassembler. During operation, the disassembler
receives a machine-code version of a computer program. In order to disassemble
a specific machine-code instruction from this machine-code version, the system
compares the machine-code instruction against a set of instruction templates for
assembly code instructions to identify a set of matching templates. Next, the system
selects a matching template from the set of matching templates based on the state
of a mode variable, which indicates a specificity mode for the disassembler. The
system then disassembles the machine-code instruction using the operand fields
defined by the matching template to produce a corresponding assembly code instruction.