UZ80 Z80 macro assembler

7184 hits
eXTReMe Tracker


UZ80 is a cross-platform Z80 assembler that aims to be both small and fast while still providing valuable services such as macro instructions and conditional assembly. Internally, it departs from full two-pass methods and relies instead on assembling as much code as possible during the first pass and writing down the lines making references to still unseen symbols; these lines will be assembled when all symbols are known.

Software and documentation are provided "as is" with no warranty.

How to use

UZ80 relies on the standard C library, it doesn't need other libraries to run. Its command line syntax is as follows: UZ80 [-q|-v] [-D[label[=value]]] [-Ipath] source [-o]target

The assembly syntax itself is as follows: Indenting is important: labels must begin on the first character of each line and instructions start later in the line even when there are no labels. Instructions are either those belonging to the Z80, or the following pseudo instructions: Expressions are similar to those used in C and in other assemblers: integers (either decimal formatted as 1234 or 1234d, hexadecimal as #1234, $1234, 1234h or 0x1234, octal as 1234o or binary as %10110111 or 10110111b) and symbols (case-insensitive; "$" stands for the current address) can endure addition ('+'), substraction ('-'), multiplication ('*'), division ('/'), modulo ('%'), logical NOT ('!'), bitwise NOT ('~'), bitwise AND ('&'), bitwise OR ('|'), bitwise XOR ('^'), left shift ('<<'), right shift ('>>') and several types of comparison ('<', '<=', '='/'==', '<>'/'!=', '>=', '>'); operation precedence follows common rules such as additions and substractions taking place after multiplications and divisions, but before comparisons, unless parentheses are used to prioritise some operations over others. Notice that "equ" and "macro" must include labels and thus need to begin on the first character of the line. An example of a macro with parameters is as follows:

memcpy macro target,source,length
 ld hl,source
 ld de,target
 ld bc,length

Using it with "memcpy buffer,string,10" generates the following code:

 ld hl,string
 ld de,buffer
 ld bc,10

The special symbols "\1", "\2", "\3"... stand for the first, second, third... parameters in the macro; the special symbol "\0" stands for the number of parameters. Local labels within a macro can be defined by appending the special symbol "\?" to the label name: "labelname\?".

Originally undocumented instructions such as SLL r, IN (C) and OUT (C) and parameters such as the high and low halves of IX and IY (XH, XL, YH and YL respectively) are supported, as well as several synonyms and shortcuts:
Macros and the pseudoinstructions "if" and "include" can be recursively nested; however, too many levels of nesting will cause a fatal error. Exit codes are either 0 (success) or 1 (fatal error); fatal errors will display a short message stating the type and location of each error.

Version log

[ ]
Download the current release (18 hits)
20231103-2555 (19) 20230626-2555 (18) 20230120-0955 (40) 20221020-2555 (28)
20220806-2555 (31) 20211030-1345 (61) 20210421-2555 (58) 20201124-1455 (67) 20201118-0930 (47)
20201109-2005 (54) 20200331-1155 (104) 20200103-1105 (86) 20191010-1925 (107) 20191003-2020 (93)
20190928-1055 (87) 20190731-2140 (111) 20190210-1150 (112) 20181130-2030 (124) 20181104-1105 (116)
20181025-1445 (122) 20180822-1850 (131) 20180822-1850 (113) 20180808-0946 (136) 20180528-2020 (124)
20180510-1255 (134) 20180506-1230 (127) 20180505-1200 (117) 20180426-1030 (135) 20180417-1920 (115)
20180414-1140 (123) 20180408-1440 (145) 20180326-1155 (118) 20180322-1930 (124) 20180321-2040 (136)
Send a comment
Return to index