![]() |
![]()
| ![]() |
![]()
NAMEdescription of the z80-asm assembly language DESCRIPTIONSource 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 by whitespace (whitespace is one or more tab, space or comma), arguments are separated by whitespace too. With the exception of strings whole line is case insensitive. And except inside strings, whitespace can never appear inside an argument. INSTRUCTIONSAssembler accepts all 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, sll, sra, sub, xor and pseudo (not Z80) instructions: * org - org accepts one address argument; it tells
* defb - defb means 8-bit data; after defb instruction
* defw - defw is similar to defb; it means 16-bit data;
* defm - defm is only instruction accepting string
* defs - defs is used to reserve storage; it is followed
* align - align is used also to reserve memory; but it is
* equ - equ defines a name to be a value; thus an equ
* defl - defl defines a name to be a value; thus an defl
* end - end indicates the assembler that source ends
* cond - cond indicates a block of statements follow for
* endc - endc indicates the end of a block of statements
A remark for the arguments of the jr and the djnz instruction: only if its address is a constant number starting with a + or - sign this value is interpreted as a signed 8 bit relative jump distance. In all other cases it is considered as an unsigned 16 bit address which must lay in the signed 8 bit distance of the instruction. ARGUMENTSInstruction argument can be one of the following:
REGISTERSStandard Z80 register identifiers are allowed:
FLAGSAssembler uses standard Z80 flag identifiers: 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. NUMBERSAssembler accepts integer numbers in binary, decimal, and hexadecimal scale. Binary numbers must be prefaced with # (number sign) or postfixed by b or B , decimal numbers are without prefix and hexadecimal numbers are either prefaced with 0x or $ prefix or with h or H postfix. Number can be also a character constant. Character constants are quoted in ' (apostrophes). Inside apostrophes there is exactly one character. Such character constants are considered as an unsigned eight-bit number. If there is no hexadecimal prefix given, the first digit of a number must be one of 0 - 9. Numbers (except for character constants) can also be negative. Negative numbers are created by writing a - (minus) symbol in front of the number (binary, decimal or hexadecimal). Then their value is represented/interpreted as 2-complement. A leading + (plus) is ignored but valid if no minus follows. Valid examples: -0x29a, -#10011011, 1234, +34H, $ffff LABELSLabel is a string consisting of characters 0-9 (digits), a-z (lower case letters), A-Z (upper case letters) or the character _ (underscore). It may not start with a digit, must contain at least one alphanumerical character but at most 63 characters. Moreover it must be different from any number, register and flag identifiers. A label is declared by writing it at the beginning of a line, no character (nor whitespace) can precede. There's no colon needed behind a label declaration, but if there is one trailing colon in the declaration it is disgarded. Each label is separated from instruction by whitespace. If you want to use a label as an instruction argument, you simply write its name. Labels can be used as (or inside) arguments before they are declared. The special label @ refers to the current value of the program counter. Label example:
EXPRESSIONSFor every argument where a label may appear an expression may
appear. An expression is an algebraic expression consisting of labels and/or
numbers (possibly prefixed by monadic operators) which are connected by
binary operators. Also you may use parentheses to change the order of
evaluation of an expression. Operators are ** for power, //
for bitsize (equivalently log_2 strictly rounded up to the next integer),
+ for addition (and also as a monadic +), - for subtraction
and also for the negation (2-complement) of an operand, * for
multiplication, / for integer division (result will always round down
if it is non integral), % for modulo (result will always non negative
if modulus is non negative), ~ for 1-complement (binary
representation is inverted bitwise), ! for boolean negation (only
zero becomes true each other value becomes false), & for bitwise
and, | for bitwise or, and ^ for bitwise exclusive or. The the
monadic operators + - ~ ! // have highest priority, then follow the
binary operator ** , the binary operators * / % which are left
associative, next the left associative binary operators + - , the
left associative binary shift operators >> and <<
then the binary left associative operator & and finally the
binary left associative operators | ^ which have even lower priority.
Moreover there are the six boolean comparision operators for signed values
== != > < >= <= which are also left associative as well
as the boolean operators && for logical and and || for
logical or which have the lowest priority. The boolean value false is
0 and boolean true is represented as ~0. The evaluation of
expressions is done in 32-bit signed arithmetic. Except the right operand of
<< >> ** and // which is always
interpreted as unsigned, all other operands are considered signed. In the
case an arithmetic overflow occurs the result will be undefined.
INDIRECTAn argument which starts with a ( (opening parenthesis) and ends with a ) (closing parenthesis) describes an indirect memory addressing. STRINGSStrings are written in quotes. Inside quotes are allowed all character codes 32-255. A " (quote character) inside must be doubled. Strings are allowed only as argument of a defm instruction and may contain at most 255 characters. String example: "hello world" COMMENTSA comment starts with a ; (semicolon) character and ends at the end of a line. Comments are ignored, they are only for programmer's use. SEE ALSOz80-asm(1), z80-mon(1), z80-file(5)
|