// Z80 ASM

The Z80 Assembler

JAMSI ships a Maxam 1.5 / compatible Z80 assembler inside the Debugger. It assembles directly into emulator RAM, writes BIN files, and reads/writes source and binary files from the virtual HDDs and DSK floppy drives.

Open the emulator →

1 · Introduction

2 · Source syntax

Use ORG &4000 or ORG #4000 to set the origin. $ is the current address.

Labels are a word (letters, digits, underscore) optionally starting with .. A label may stand alone on its line or before an instruction: start: LD A,1 or start LD A,1. .local labels are allowed.

Assign values with LABEL EQU value or LABEL = value. LET LABEL = value redefines a symbol.

3 · Directives

Data: DB/DEFB/BYTE/DM emit bytes; DW/DEFW/WORD emit words; DS/DEFS/RMEM reserve space (fill); STR emits a string with the last character high-bit set.

Control: ORG, ALIGN boundary[,fill], END, LIST/NOLIST, CODE/NOCODE, PRINT, NOHEADER.

Conditional: IF/ELSEIF/ELSE/ENDIF, IFDEF/IFNDEF/IFNOT.

Loops: REPEAT nREND and WHILE condWEND.

RAM banks: BANK C0 selects the base 64K; BANK C4BANK C7 select one of the four 128K banks that appear at &4000&7FFF. A bank change acts like an ORG boundary — code goes into a separate physical bank.

4 · Expressions

Maxam

Expressions are evaluated left to right with NO operator precedence (Maxam behaviour). Use parentheses to group.

Operators: + - * / MOD AND OR XOR SHL SHR NOT, unary minus. Hex: &4000, #4000, 4000H, 0x4000. Binary: %1010. Char: 'A'. Current address: $.

2 * 4 + x is (2*4)+x; x + 2 * 4 is (x+2)*4.

5 · Files, HDDs & floppies

Drive letters address the storage: a:/b: are the DSK floppies, c:-f: are HDDs 1–4.

READ "c:/app/lib.asm" includes a source file from HDD1. INCBIN "c:/data.bin" embeds binary data; an AMSDOS header is stripped automatically.

Relative paths resolve against the including file's directory: a READ "graphics.asm" inside c:/app/lib.asm loads c:/app/graphics.asm. DSK floppies have no folders; HDDs do.

The VFS button in the assembler lists files on the active HDD; Include adds a READ "…" line.

6 · Macros & conditional assembly

Define a macro with NAME MACRO p1,p2MEND, then call NAME arg1,arg2. Parameters are substituted (case-insensitive); @label inside a macro becomes a local label.

The assembler also expands REPEAT/REND and WHILE/WEND loops, which may contain local @ labels.

7 · Writing output

WRITE DIRECT "a:MYFILE.BIN" writes the assembled bytes as a file into the mounted DSK of drive A (or b:). It gets an AMSDOS header with load/exec = ORG and length = the full assembled size. Use NOHEADER before it to save without a header.

WRITE "c:/app/out.bin" writes the assembled bytes into a HDD. Writing to a drive you do not have (e.g. e: with only 2 HDDs) is an error.

Multi-ORG

If the program contains several ORG regions at different addresses (including from included files), each region is written as its own file. The first region keeps the name (PROG.BIN), later ones get a numbered extension: PROG.BI1, PROG.BI2 … Each file gets its region's ORG as the AMSDOS load address.

Banks

Banked regions are written with a per-bank tag: BANK C4 produces PROG.BC4, BANK C7 PROG.BC7, and so on. Base (C0) regions keep the plain name / numbered extension (PROG.BIN, PROG.BI1 …).

Save BIN

Save BIN downloads the assembled result. When the program is split over several regions (multiple ORGs or banks), it delivers a ZIP with one file per region, named exactly as WRITE would: PROG.BIN, PROG.BI1, PROG.BC4 … Each file carries its own AMSDOS header when “Add Header” is enabled.

Inject

Inject to RAM writes only the bytes that were actually assembled — unassembled gaps are left untouched. Banked regions (C4–C7) are written into the matching physical bank; the previous bank selection is restored afterwards.

Example

ORG &4000
NOHEADER
WRITE DIRECT "a:myfile.bin"
LD A,&80
RET

8 · Editor & local files

Tabs

You can open multiple source files in tabs. The plus button (+) adds a new tab, the ✕ closes one. Each tab keeps its own source text and its own assembly result.

The editor auto-indents: pressing Enter starts the new line with the same leading tabs/spaces as the current line, keeping column-aligned code tidy. Tab inserts four spaces.

The SOURCE FILE row lets you load (Load) and save (Save ASM) a source file. Paths such as c:/app/my.asm address the HDD, a:MY.ASM/b:MY.ASM a floppy (headerless). Loaded files open in a new tab.

Local

Open Local… opens a folder from your PC (Chrome/Edge) and loads every .asm/.txt/.z80 file in it as a tab.

Relative includes resolve from that local folder: if myfile.asm contains READ "my2ndfile.asm" and the file is in the same folder, it is found automatically. WRITE directives still target the HDD/disk.

← Back to the user guide · Open the emulator