Z80 Dependent Features
**********************

Options
=======

The Zilog Z80 and Ascii R800 version of AS have a few machine dependent options.

-z80
     Produce code for the Z80 processor. There are additional options to request warnings and error messages for undocumented instructions.

-ignore-undocumented-instructions
-Wnud
     Silently assemble undocumented Z80-instructions that have been adopted as documented R800-instructions.

-ignore-unportable-instructions
-Wnup
     Silently assemble all undocumented Z80-instructions.

-warn-undocumented-instructions
-Wud
     Issue warnings for undocumented Z80-instructions that work on R800, do not assemble other undocumented instructions without warning.

-warn-unportable-instructions
-Wup
     Issue warnings for other undocumented Z80-instructions, do not treat any undocumented instructions as errors.

-forbid-undocumented-instructions
-Fud
     Treat all undocumented z80-instructions as errors.

-forbid-unportable-instructions
-Fup
     Treat undocumented z80-instructions that do not work on R800 as errors.

-r800
     Produce code for the R800 processor. The assembler does not support undocumented instructions for the R800. In line with common practice, AS uses Z80 instriction names for the R800 processor, as far as they exist.

Syntax
======

The assembler syntax closely follows the 'Z80 family CPU User Manual' by Zilog. In expressions a single = may be used as ``is equal to'' comparison operator.

Suffices can be used to indicate the radix of integer constants; H or h for hexadecimal, D or d for decimal, Q, O, q or o for octal, and B for binary.

The suffix b denotes a backreference to local label.

Special Characters
------------------

The semicolon ; is the line comment character;

The dollar sign $ can be used as a prefix for hexadecimal numbers and as a symbol denoting the current location counter.

A backslash \ is an ordinary character for the Z80 assembler.

The single quote ' must be followed by a closing quote. If there is one character inbetween, it is a character constant, otherwise it is a string constant.

Register Names
--------------

The registers are referred to with the letters assigned to them by Zilog. In addition AS recognises ixl and ixh as the least and most significant octet in ix, and similarly iyl and  iyh as parts of iy.

Case Sensitivity
----------------

Upper and lower case are equivalent in register names, opcodes, condition codes  and assembler directives. The case of letters is significant in labels and symbol names. The case is also important to distinguish the suffix b for a backward reference to a local label from the suffix B for a number in binary notation.

Floating Point
==============

Floating-point numbers are not supported.

Z80 Assembler Directives
========================

AS for the Z80 supports some additional directives for compatibility with other assemblers.

These are the additional directives in AS for the Z80:

db EXPRESSION|STRING[,EXPRESSION|STRING...]
defb EXPRESSION|STRING[,EXPRESSION|STRING...]
     For each STRING the characters are copied to the object file, for each other EXPRESSION the value is stored in one byte. A warning is issued in case of an overflow.

dw EXPRESSION[,EXPRESSION...]
defw EXPRESSION[,EXPRESSION...]
     For each EXPRESSION the value is stored in two bytes, ignoring overflow.

d24 EXPRESSION[,EXPRESSION...]
def24 EXPRESSION[,EXPRESSION...]
     For each EXPRESSION the value is stored in three bytes, ignoring overflow.

d32 EXPRESSION[,EXPRESSION...]
def32 EXPRESSION[,EXPRESSION...]
     For each EXPRESSION the value is stored in four bytes, ignoring overflow.

ds COUNT[, VALUE]
defs COUNT[, VALUE]
     Fill COUNT bytes in the object file with VALUE, if VALUE is omitted it defaults to zero.

SYMBOL equ EXPRESSION
SYMBOL defl EXPRESSION
     These directives set the value of SYMBOL to EXPRESSION. If equ is used, it is an error if SYMBOL is already defined. Symbols defined with equ are not protected from redefinition.

set
     This is a normal instruction on Z80, and not an assembler directive.

psect NAME
     A synonym for see Section, no second argument should be given.

Opcodes
=======

In line with commmon practice Z80 mnonics are used for both the Z80 and the R800.

In many instructions it is possible to use one of the half index registers (ixl,ixh,iyl,iyh) in stead of an 8-bit general purpose register. This yields instructions that are documented on the R800 and undocumented on the Z80. Similarly in f,(c) is documented on the R800 and undocumented on the Z80.

The assembler also supports the following undocumented Z80-instructions, that have not been adopted in the R800 instruction set:

out (c),0
     Sends zero to the port pointed to by register c.

sli M
     Equivalent to M = (M<<1)+1, the operand M can be any operand that is valid for sla. One can use sll as a synonym for sli.

OP (ix+D), R
     This is equivalent to

          ld R, (ix+D)
          OPC R
          ld (ix+D), R

     The operation OPC may be any of res B,, set B,, rl, rlc, rr, rrc, sla, sli, sra and srl, and the register R may be any of a, b, c, d, e, h and l.

OPC (iy+D), R
     As above, but with iy instead of ix.

The web site at http://www.z80.info is a good starting place to find more information on programming the Z80.