# ExportDisasm

> **Tool `tools/ghidra/ExportDisasm.java`** (ghidra, Ghidra scripts). Write a disassembly listing (address, bytes, instruction) from an analysed project.

A Ghidra script: `scripts/ghidra-export.sh` and `scripts/ghidra-run.sh` run it headless. [Source on GitHub](https://github.com/tanepiper/game-frame/blob/main/tools/ghidra/ExportDisasm.java).

## Its own help

This is the help text in the tool itself, as `./gameframe tool ExportDisasm` prints it.

```text
Write a disassembly listing (address, bytes, instruction) from an analysed project.
Usage: analyzeHeadless PROJECT NAME -process PROGRAM -noanalysis -scriptPath tools/ghidra \
  -postScript ExportDisasm.java OUTPUT.txt [ADDRESS | START-END ...]
  (or scripts/ghidra-run.sh BINARY disasm OUTPUT [ADDRESS | START-END ...])

ADDRESS        the function that contains it; one is made there if Ghidra has none (code that
               only a table or a run-time call reaches)
START-END      every instruction from START up to END, decoded in order whether or not it is in
               a function: blocks of short entry stubs that jump into shared code, data the
               analysis left between functions
no arguments   every function of the program

For checking arithmetic, flags and instruction counts against a port, where pseudocode is not
exact enough. Undecodable bytes are listed as "??". It does not save the project unless it made
a function. Keep the output in analysis/ (git-ignored): it reproduces the program's code.
```
