Skip to Content
GuidesDebuggingThe Disassembly view

The Disassembly View

The Disassembly view shows memory as Z80 instructions, around the execution point or across the whole address space. Use it to see the code that actually runs (ROM routines, code your program generated, a program loaded from tape), to set breakpoints where there is no source, and to see which way each conditional branch will go.

The Disassembly view, paused at the execution point.
The Disassembly view paused at the execution point: the toolbar, the memory map, the registers, the listing with flow arrows and the inspector

Open it

Choose View › Machine Views › Disassembly, or click Show Disassembly Panel on the IDE toolbar.

With Follow PC on (the default), the view disassembles about 1024 bytes from the program counter and follows it as you step. Turn it off to disassemble the whole memory, or one partition. The show-disass command opens the view at an address, a label, a register or a partition and offset.

Breakpoints in the gutter

The narrow gutter left of each address holds the row’s breakpoint:

GestureDoes
Right-clickAdds an execution breakpoint, or removes the one there
Double-click a breakpointOpens the breakpoint dialog, where you can change its Type to memory read or write, I/O, and the rest, and add a condition
Shift+clickAdds a one-shot breakpoint, or toggles one-shot
Ctrl+click (Cmd+click on macOS)Runs to this row

Hover the gutter to see these gestures in a tooltip. Right-clicking elsewhere on a row opens a menu with the same actions by name (Add Breakpoint / Remove Breakpoint, Add One-Shot Breakpoint, Run to Here and Edit Breakpoint…), followed by the annotation entries (Label…, End-of-Line Comment… and others), which are described in Annotating a disassembly and ROMs. Breakpoints of any type can also be set in the Breakpoints panel or with bp-set.

The toolbar

  • Go to: an address, a register, a label or a partition and offset, as in the Memory view. An address inside an instruction settles on the next instruction. Ctrl+G puts the cursor there.
  • ▶ PC: go to the execution point (while the machine is paused).
  • Follow PC: follow the program counter, as above. The button after it refreshes the listing.
  • Find: see Find.
  • Hex / Dec: the number format of addresses, bytes and operands.
  • Sys vars: name 16-bit data addresses after the machine’s system variables (on by default). See System variable names.
  • ROM labels: show the ROM’s annotations: its labels, comments and data regions (on by default; shown when the machine’s ROM has annotations). See ROM annotations.
  • Flow: draw the flow arrows.
  • RAM: and Screen: (with Follow PC off): disassemble the RAM (on by default) and the screen memory at $4000-$5AFF (off by default).
  • Origin (with one partition shown): the address the partition is disassembled at.
  • Export and the reverse-engineering tools, then Inspector, which shows the inspector column when a row is selected.

Under the toolbar are the memory map, the partition row and the register strip of the Memory view; the register strip adds an F chip with the flags (SZ5H3PNC, a capital for a set flag), which the branch verdicts are judged against. With the 64K shown, a rule row marks where the listing enters another slot, and names the partition there. An empty Cambridge Z88 card slot is one row instead of 16K of rst $38.

Flow arrows

Flow arrows: dashed for a conditional jump, highlighted for the selected row.
The flow gutter: arrows from JR, JP and DJNZ instructions to their targets, the selected row's highlighted

The column between the breakpoint gutter and the address draws an arrow from each JR, JP and DJNZ to its target, in up to eight lanes, the shortest innermost. A conditional jump’s arrow is dashed. The jumps of the selected row are highlighted, and the branch the CPU takes at the execution point is drawn in the verdict colour.

A jump over more than about a screen of rows gets a short stub at each end instead of a line across the listing, and a jump whose target is outside the listing a stub pointing up or down. CALL and RST have no arrow: their branch mark (an out-and-back hook) says they return.

Labels and references

A row with a label shows after it how many rows of the listing name that label (◂ 3). Click the count to list those rows in the inspector’s Referred to by section, and click one there to go to it. These are the rows on which you read the name, the rule Go to References follows.

Find

Type in Find and press Enter: it searches the listing as printed, mnemonics, operands (names included), labels and comments, so rst $10, LAST_K and a label all work. F3 and Shift+F3 step through the matches, selecting each row.

The inspector

The inspector of the selected instruction.
The Disassembly view's inspector: the instruction, its verdict, its operands, its annotation and its breakpoint

Click a row, or move with the arrow keys, and the inspector describes it:

  • Instruction: as printed, its bytes, its length and its T-states (taken and not taken).
  • Verdict: for a branch, what it will do; certain at the execution point, otherwise what would happen if the CPU arrived here now.
  • Operands: each address the instruction names, with its name, its partition and offset and the first bytes there, and Go to and Memory ↗. An indirect operand such as (HL) or (IX+5) is resolved from the registers; a NEXTREG links to the register.
  • Referred to by: the rows that name this row’s label.
  • Annotation: the row’s label and comment, and the Label…, End-of-Line Comment… and other entries of the row menu. An edit is saved at once.
  • Breakpoint: Add Breakpoint, Add One-Shot Breakpoint, Run to Here and Edit Breakpoint….
  • Use: Show in Memory (Ctrl+M), at the same address and partition.

System variable names

Wherever an instruction loads or stores through a literal 16-bit address, and that address is one of the machine’s system variables, the view prints the variable’s name instead of the number:

ld hl,LAST_K ld (ERR_NR),a ld sp,RAMTOP ld (CHANS),hl

The names come from the same table the System Variables panel lists, so each machine contributes its own: the ZX Spectrum 48K, 128K and +3, the ZX Spectrum Next, the ZX81 and the ZX80 each have one. Names are spelled so an assembler would accept them: the ROM manuals print several with a space or a hyphen (ATTR P, CH-ADD), and every character that is not a letter, a digit or an underscore becomes _, so those read ATTR_P and CH_ADD.

💡

Only data operands are named: the 16-bit loads and stores. JP and CALL targets keep their L-prefixed labels, because the system variable area is not code: an address there matching a jump target is a coincidence far more often than a fact worth printing. Naming applies to the Z80 and Z80N machines.

The Sys vars switch turns the naming off and on. It is on by default, each view remembers its own setting, and turning it off shows the addresses exactly as they were before.

The same naming appears in the disassembly of a popped-out .NEX bank, with its own Sys vars switch. There, a label you wrote yourself always wins: your label says something about this program, while a system variable name only states a fact about the machine.

Branch verdicts

While a machine is running or paused, the Disassembly View marks every conditional branch it can see with what that branch will do next, worked out from the CPU’s current flags and registers. A narrow column between the T-states and the instruction carries the mark:

Branch marks, and the readout at the execution point.
Branch marks in the Disassembly view: a loop closing backwards at the execution point with its readout, and marks for calls, returns and jumps

The execution point is a branch about to be decided, and the readout beside it says where to, which condition decided it, and what that costs. The rows around it carry the marks of the other branches: returns, calls drawn as an out-and-back hook, and jumps.

MarkMeaning
Arrow pointing upThe branch will jump backwards, to an address at or below its own: a loop closing.
Arrow pointing downThe branch will jump forwards, skipping the code between.
Out-and-back hookA CALL or RST that will be taken: control leaves and comes back.
Arrow pointing leftA RET or RET cc that will return, leaving through the stack.
Dashed arrow pointing rightControl leaves, but the destination cannot be worked out. See below.
Straight vertical lineThe branch will not be taken; execution carries straight on to the next instruction.

Five of the six say which way control goes; the hook says something different, that control will return here afterwards. A CALL therefore looks the same whether its target is above or below (it is a call either way), while a JP to the same address shows a plain arrow. RST n is CALL n in a one-byte encoding, so it takes the hook too, and its readout says calls $0008 rather than naming a direction.

A taken branch’s mark is highlighted; a fall-through’s is drawn plainly. Falling through is not an error, so it is never marked the way breakpoints and the execution point are.

Certain and speculative marks

The mark on the row at the execution point is drawn at full strength, because the flags it was worked out from are the flags the CPU will actually use.

Every other mark is dimmed, and this difference matters. A branch ten instructions below PC is judged against today’s flags, not the flags that will hold when execution finally reaches it, and the code in between will almost certainly change them. Read a dimmed mark as “this is what would happen if the CPU arrived here right now”, not as a prediction.

The execution point readout

The row at the execution point also spells the verdict out in full, after the instruction:

jumps back to $0EFD · NC met (C=0) · 12 T

It names where execution goes next, which condition decided it, the flag value behind that decision, and the T-states the instruction will actually spend: a conditional branch costs a different number of cycles depending on which way it goes, and this is the one it will really take.

In a narrow panel the readout shortens to → $0EFD C=0 12T. Hover it to see the full sentence.

💡

Verdicts appear only when a machine is started. With no machine running there is no CPU state to judge against, so the view looks exactly as it always has, with no extra column, no shifted layout. Verdicts are shown for Z80 and Z80N machines only.

Destinations that cannot be worked out

Three cases show a verdict but no destination, on purpose:

  • JP (C) on a ZX Spectrum Next jumps to an address whose low bits come from reading an I/O port. That read has not happened yet, and performing it only to fill in a debugger display would disturb the machine you are debugging. The readout says so rather than guessing.
  • RET cc away from the execution point. The return address sits on the stack, and the top of the stack belongs to whatever is executing now, not to the row you are looking at. It is only shown for the row at PC, where it is genuinely that instruction’s return address.
  • RET cc in a partition shown on its own. The view then holds one partition rather than the whole address space, so the stack is not part of what is on display.

While the machine is free-running rather than paused, the marks follow the CPU state as it is sampled, a few times a second. Pause or single-step for a verdict that stands still.

Looking at one partition

The Partitions row picks the 64K or one partition, as in the Memory view. A partition on its own is disassembled at an Origin: where it is paged in now, or $0000 when it is not. Change it in the toolbar’s Origin chooser (8K page boundaries) so the addresses match where the code runs.

A Z88 bank on its own, at its Origin.
A Cambridge Z88 bank disassembled on its own at an Origin

The ROM’s own annotations follow the ROM page wherever it is shown:

The 48K ROM, annotated: labels, synopses and comments from its sidecar.
The 48K ROM in the Disassembly view, with its labels, synopses and comments

The partition names are those of the Memory view.

A ZX Spectrum Next bank can also be popped out into its own document, with live contents and breakpoints relative to the bank; see Running and inspecting NEX files.

Last updated on