Z80DASM(1)

๐Ÿ“ฆ
version 1.1.6 ยท 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

z80dasm โ€” the Z80 assembly generating disassembler, bestie edition ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

z80dasm [ options ] file

๐ŸŒธ DESCRIPTION ๐ŸŒธ

Okay so listen. z80dasm takes a binary file full of Z80 machine code and disassembles it into actual Z80 assembly language source. And yes, it handles a bunch of undocumented opcodes too, because it's an overachiever and we love that for it. ๐Ÿ‘‘

It can try to guess where the labels go in the code โ€” or you can just tell it yourself by hand, in the form of a symbol file. And if you feed it the right info, it can also split that binary file into code sections and data sections of several different types. Multi-talented fr fr. ๐Ÿ’…

The source file it spits out? You can assemble it right back into the original binary using z80asm, zasm, or the original Zilog assembler (that last one only when you used the --zilog option, iykyk).


๐ŸŽ€ OPTIONS ๐ŸŽ€

  • -a, --address โ€” Prints the address of the memory location that corresponds to each line of assembly code, as a comment at the end of the line. Little breadcrumb trail, love that. โœจ
  • -b, --block-def=FILE โ€” Reads block information from a file. Don't specify it? Then the default is that the entire file is machine code. Peep the BLOCK FILE section below for the deets.
  • -g, --origin=ORG โ€” Sets the start address of the binary code you're disassembling, and a matching org directive gets generated in the output file. The argument is read as hexadecimal if it starts with 0x or 0X, as octal if it starts with 0, and base 10 otherwise. Default is 0x0100. ๐Ÿซถ
  • -h, --help โ€” Shows a summary of the options and dips. Byeee ๐Ÿ‘‹
  • -l, --labels โ€” Tries to guess where the labels go based on jump instructions, then adds them into the assembly code. Psychic energy, honestly. ๐Ÿ”ฎ
  • -o, --output=FILE โ€” Picks the output file. Default is writing to standard output.
  • -r, --sym-order=SORT โ€” The ordering of symbols in the symbol file. SORT can be default (sorted by value) or frequency (sorted by how often they're used).
  • -s, --sym-output=FILE โ€” Writes symbol information into a file. ๐Ÿ’พ
  • -S, --sym-input=FILE โ€” Reads symbol information from a file. Check the SYMBOL FILE section below.
  • -t, --source โ€” Prints the binary data that corresponds to each line of assembly code, as a comment at the end of the line. Data comes out in hex and ASCII. Super useful for spotting data sections on that first disassembly pass. ๐Ÿ”
  • -u, --undoc โ€” By default, all undocumented instructions get disassembled as defb directives with the instruction name tucked into a comment. Why? Because z80asm has missing or buggy support for a lot of these instructions, no cap. If you pass this option, those undocumented instructions get written directly into the disassembly. Live dangerously. ๐Ÿ’€
  • -v, --verbose โ€” Cranks up the verbosity level. Specify it multiple times to get even more verbose. Messages go to standard error.
  • -V, --version โ€” Displays version info and exits.
  • -z, --zilog โ€” Turns on compatibility mode for the original Zilog Z80 assembler. Right now it only changes the syntax of relative jumps. Small but mighty. โญ

๐Ÿงš SYMBOL FILE ๐Ÿงš

Symbol files that z80dasm writes can be fed straight back in as input symbol files with the --sym-input option. Cute little round trip, we stan. ๐Ÿ’œ

These directives are recognized in input symbol files, and they get propagated to the output symbol files:

  • include "filename" โ€” Includes another symbol file. The double quotes are mandatory, bestie. And the included files have to be in the current directory.
  • symbol: equ value โ€” Defines a symbol with a value. The value is read as hexadecimal if it begins with 0x or 0X, as octal if it begins with 0, and base 10 otherwise. Default is 0x0100.
  • ; comment โ€” Everything between a semi-colon and the end of the line is ignored. ๐Ÿšซ

๐Ÿฆ‹ BLOCK FILE ๐Ÿฆ‹

Block files specify the boundaries between different blocks (aka sections) of binary data in the disassembler's input file. These directives are recognized:

  • name: [ unlabeled ] [ start | first ] address [ unlabeled ] [ end | last ] address type type โ€” Defines a block with a start and end address that holds a certain type of binary data.

Start address is the 16 bit address of the first byte in the block. The keywords start and first mean the exact same thing, synonymous besties. ๐Ÿซถ

If you use the end keyword, the end address is the 16 bit address of the last byte in the block plus one. If you use last, the end address is the 16 bit address of the last byte in the block. Subtle but important, don't mix them up. ๐Ÿ˜ญ

Normally labels get defined at the addresses you specified in the block definition. You can suppress that by adding the keyword unlabeled before the address.

  • ; comment โ€” Everything between a semi-colon and the end of the line is ignored. Same deal as before.

And here are the block types it supports, queen energy only:

  • code โ€” A block containing Z80 machine code. Data in this block gets written as Z80 assembly language. ๐Ÿ‘‘
  • bytedata โ€” A data block containing separate bytes. Data here gets written with defb directives.
  • worddata โ€” A data block containing 16 bit words (low order byte first). Data here gets written with defw directives.
  • pointers โ€” A data block containing 16 bit pointers (low order byte first). This type is equivalent to worddata except that values get replaced with labels wherever that's possible. โœจ

๐Ÿ’… DIAGNOSTICS ๐Ÿ’…

If the disassembly went well, z80dasm returns 0. On error, diagnostic messages get printed to standard error and z80dasm returns 1. That's the vibe check. โœ…


๐Ÿ’€ BUGS ๐Ÿ’€

Please report bugs to tomaz.solc@tablix.org โ€” do not suffer in silence, bestie, tell them everything. ๐Ÿ™ˆ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

z80dasm is based largely on dz80, written by Jan Panteltje. Feature enhancements and bug fixes were made by Tomaz Solc. Legends only. ๐ŸŒŸ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


Okay that's the whole page, mwah ๐Ÿ’‹ This one's by Tomaz Solc, dated 2007-06-14, and it lives in the Z80 disassembler User's manual as Z80DASM(1). Go disassemble something iconic. ๐ŸŽ€โœจ