

Design of the LLVM disassembler - alec
http://blog.llvm.org/2010/01/x86-disassembler.html

======
barrkel
Without looking into the code, it's not clear that the article explains the
mechanism very well, or even enough to say something interesting. What's a
ContextDecision? What's an OpcodeDecision? And ModRMDecision? Are they enums,
bitflags, indexes, objects?

The most obvious way to write a disassembler (to my mind) specifically for
such an idiosyncratic architecture as x86 is a 256-way lookup table mapping
the first byte to hand-crafted instruction decoder functions, carefully placed
to take advantage of commonalities among certain classes of opcodes. Add some
flags into the table and you can extract more commonality. Addressing modes
from Mod R/M and SIB can be factored out into separate routines. It adds up to
a bunch of grunt work, but ought to be very fast.

