Igor’s Tip of the Week #135: Exporting disassembly from IDA

Although most of the time you can probably do all of the reversing inside IDA, occasionally you may need to continue it using other tools. While sometimes it may be enough to analyze the input file with another tool, or use the Export Data feature, the disassembly listing is more convenient in many cases. Of course, you can use the clipboard to copy some snippets, but this can be awkward and slow if you need big chunks of the listing, or need to remove unnecessary parts of the listing such as the address prefixes.

ASM file

ASM files can be generated by using the menu entry File > Produce File > Create ASM File…, or the shortcut AltF10.

By default, the contents of the whole database is exported, but you can select a range before invoking the command to limit it to just what you need. If you need multiple fragments, you can repeat the action several time, choosing “Append” when IDA informs you that the file already exists.

In ideal circumstances, the ASM listing can be passed to the assembler to generate code equivalent to the original binary. It means it does not contain extra annotations which may be present in IDA, such as address prefixes or opcode bytes. Of course, the reality is often not so simple, but minor modification to the ASM file may be enough to solve your problem.

LST file

The LST file can be generated via the menu entry File > Produce File > Create LST File… (no default shortcut). Unlike the ASM file, it contains all the information present in IDA’s text view, so it can be useful if you want to see opcode bytes or address prefixes.

Protip

The ASM or LST file usually needs at least one line of text per each instruction or data item. If your database contains large data areas, converting them to arrays before exporting can reduce the size of the output files significantly. Hiding or collapsing uninteresting areas or whole segments is another option.