UZ80
UZ80 Z80 macro assembler

7631 hits
eXTReMe Tracker

Foreword

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
 ldir
 endm

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

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

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


[ cpcrulez.fr ]
Download the current release (64 hits)
20231103-2555 (35) 20230626-2555 (37) 20230120-0955 (56) 20221020-2555 (48)
20220806-2555 (50) 20211030-1345 (79) 20210421-2555 (82) 20201124-1455 (85) 20201118-0930 (66)
20201109-2005 (73) 20200331-1155 (123) 20200103-1105 (106) 20191010-1925 (127) 20191003-2020 (111)
20190928-1055 (105) 20190731-2140 (130) 20190210-1150 (131) 20181130-2030 (143) 20181104-1105 (137)
20181025-1445 (143) 20180822-1850 (150) 20180822-1850 (134) 20180808-0946 (154) 20180528-2020 (144)
20180510-1255 (154) 20180506-1230 (146) 20180505-1200 (137) 20180426-1030 (153) 20180417-1920 (133)
20180414-1140 (143) 20180408-1440 (165) 20180326-1155 (138) 20180322-1930 (142) 20180321-2040 (154)
Send a comment
Return to index