Z80-ASM(5)

NAME
description of the z80-asm assembly language

DESCRIPTION
Source code compounds of lines. Each line contains max. one instruction. Line can be divided into three parts: label, instruction and arguments. These parts are separated with whitespace (whitespace one or more tab, space or comma), arguments are separated with whitespace too. Excepting strings whole line is case insensitive.

INSTRUCTIONS
Assembler accepts usual Z80 instructions:

adc, add, and, bit, call, ccf, cp, cpd, cpdr, cpi, cpir, cpl, daa, dec, di, djnz, ei, ex, exx, halt, im, in, inc, ind, ini, indr, inir, jp, jr, ld, ldd, ldi, lddr, ldir, neg, nop, or, otdr, otir, out, outd, outi, pop, push, res, ret, reti, retn, rl, rla, rlc, rlca, rld, rr, rra, rrc, rrca, rrd, rst, sbc, scf, set, sla, sra, sub, xor

and special (not Z80) instructions:

* org - org accepts one adderss argument; it tells
         the compiler to write following code to memory
         from mentioned address; if there's no org
         instruction at the start of the source,
         assembler stores code from address 0 * defb - defb means 8-bit data; after defb instruction
         follow discretionary number of 8-bit numbers
         (or character constants); * defw - defw is simmilar to defb; it means 16-bit data;
         this instruction takes 16-bit numbers as
         arguments * defs - defs is only instruction accepting string
         arguments; it accepts arbitrary number of
         strings; strings are stored in memory
         character after character as they're written
         in string

 Instruction argument can be on of following:
    * number or character constant
    * register
    * flag
    * string
    * label
    * indirect (number, label or index registers)

NUMBERS
Assembler accepts integer numbers in binary, decimal, hexadecimal scale.

Binary number is prefaced with % (per cent character), decimal numbers are without prefix and hexadecimal numbers are prefaced with 0x prefix.

Number can be also a character constant. Character constants are quoted in ' apostrophes ' apostrophes there's exactly one letter. Character constants are considered as an unsigned eight-bit number.

Numbers (except for character constants) can also be negative. Negative numbers can be created with writing - (minus) symbol in front of the number (binary, decimal or hexadecimal).

For example: -0x29a, -%10011011, -1234

STRINGS
Strings are written in quotes. Inside quotes are allowed all characters 32-255 excepting quote character. Strings are allowed only with defs instruction.

String example: "hello world"

FLAGS
Assembler uses standard Z80 flags: C, NC, Z, NZ, P, M, PE, PO. Meaning is in sequence carry, non carry, zero, non zero, plus, minus, parity even and parity odd.

REGISTERS
Standard Z80 registers are allowed:
 8-bit registers: A, F, B, C, D, E, H, L, I, R
 16-bit registers: AF, AF', BC, DE, HL, IX, IY, SP

LABELS
Label is declared with writing it at the beginning of a line, no character (nor whitespace) can precede. Label is a string containing no whitespaces, it must be different from any numbers, registers and flags. Label is separated from instruction with whitespace. There's no colon needed behind label.

If you want to use label as an instruction argument, you simply write the label string. Labels can be usedas arguments before they're declared.

Label example:
 cycle djnz cycle
 test1 sub 10
        cp 42
        jr z,ok

COMMENTS
A comment start with a ; (semicolon) character and end at the end of a line. Comments are ignored, they're only for programmer's use.

SEE ALSO
z80-asm(1), z80-dis(1), z80-file(5)