# The x86 Disassembler

DevFeed: [The x86 Disassembler](<https://devfeed.tech/articles/the-x86-disassembler-42842.md>)

Original publisher: [Read original article](<https://blog.llvm.org/2010/01/x86-disassembler.html>)

Author: Spyffe

Published: 2010-01-06T13:34:00Z

Content type: tutorial

Language: en

Sources: [LLVM Project](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [x86](<https://devfeed.tech/topics/x86.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [gdb](<https://devfeed.tech/topics/gdb.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [software-development](<https://devfeed.tech/topics/software-development.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [binary-analysis](<https://devfeed.tech/tags/binary-analysis.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [debugger](<https://devfeed.tech/tags/debugger.md>), [gdb](<https://devfeed.tech/tags/gdb.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [mc](<https://devfeed.tech/tags/mc.md>), [new-in-llvm-2-7](<https://devfeed.tech/tags/new-in-llvm-2-7.md>), [x86](<https://devfeed.tech/tags/x86.md>)

## AI overview

This technical article explains LLVM's x86 disassembler, including why disassemblers matter for binary analysis and debugging, the performance and memory properties they should have, and how LLVM MC represents and decodes instructions.

## Source excerpt

Disassemblers make binary analysis work. With a reliable disassembler, you can solve high-level problems like tracing back through a program's call stack or analyzing sample-based profiles to low-level problems like figuring out how your compiler unrolled a tight floating-point loop or what advantages declaring a variable const actually had at the other end of the optimization chain. A reliable disassembler, which takes sequences of bytes and prints human-readable instruction mnemonics, is a crucial part of any development platform. You're about to go on a whirlwind tour of the LLVM disassembler: why one should exist, what's great about this one, and how you can use it. The case for an LLVM-based disassemblerDisassemblers are all over the place. A disassembler you may well be familiar with is the disassembler from GNU gdb (source). In fact, any debugger needs one: Sun mdb has a disassembler too (source). Some specialized applications like Dtrace need disassemblers as well (source). So because this is well-traveled ground, there are several common properties you should expect from a disassembler: A large library can contain hundreds of thousands of instructions, so disassembly must be fast. A disassembler with a large memory footprint can steal memory and cache from analysis algorithms that need them more, so its code and data should be compact. Because disassemblers are used in a variety of applications, they should provide information about instructions in a generic, preferably even architecture-independent form. For the benefit of future code maintainers, disassemblers should be as table-driven as possible. Enter the LLVM MC architecture. In MC, instructions are represented using the architecture-independent MCInst class (include/llvm/MC/MCInst.h). The translation between MC instructions and machine code is specified by pre-existing TableGen tables (lib/Target/X86/X86.td for x86 platforms). Writing a disassembler inside the MC framework makes sense because it solv