Exporting Source
Once a program is annotated, you can turn it into source code: Klive Z80 assembly with your labels, comments and data regions, that reassembles to exactly the bytes it came from.
Use Export as Source… from the tools button of the Disassembly view or a bank document, or Export as Source on a named graphic. The command takes a range of the 64K view or a whole bank:
export-asm game.kz80.asm $8000 $9fff -open
export-asm bank3.kz80.asm -bank 3Proven, not hoped for
After writing the file, Klive assembles it and compares the result with the bytes:
Byte-identical: yesIf anything differs, the first differing addresses are listed instead.
The export takes care of the cases where a disassembly’s text would not assemble back to the same bytes:
- Non-canonical encodings — the
NEGandRETNmirrors, the alternativeIMencodings, the longLD (nn),HL, aDD/FDprefix that has no effect, undefinedEDopcodes — are written as.defbwith the instruction in the comment. - An instruction that runs past its region is written as the bytes the region holds.
- Copper and DMA programs, and the ROM’s inline
RST $08/RST $28bytes, are.defbwith their decoding as the comment. - A label the assembler would not accept (
hl,ld, a name that differs from another only in case) is renamed, and the output says how. - A name used in an operand but defined outside the range — a ROM routine, a label in another
bank — becomes
NAME .equ $NNNN. - A skip region is exported as its bytes;
-skip gapleaves it out and starts a new.orginstead, and says the result is shorter.
A 128K bank is assembled into its bank with .model Spectrum128 and .bank; a Next export uses
.model next for the Next’s own instructions.
-noverify skips the check. The export is always written in Klive’s own assembly dialect.