1 @c This is part of the GAS manual.
2 @c For copying conditions, see the file as.texinfo.
7 @chapter Z80 Dependent Features
12 @node Machine Dependencies
13 @chapter Z80 Dependent Features
18 * Z80 Options:: Options
20 * Z80 Floating Point:: Floating Point
21 * Z80 Directives:: Z80 Machine Directives
22 * Z80 Opcodes:: Opcodes
28 @cindex options for Z80
29 The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
32 @cindex @code{-z80} command line option, Z80
34 Produce code for the Z80 processor. There are additional options to
35 request warnings and error messages for undocumented instructions.
36 @item -ignore-undocumented-instructions
38 Silently assemble undocumented Z80-instructions that have been adopted
39 as documented R800-instructions.
40 @item -ignore-unportable-instructions
42 Silently assemble all undocumented Z80-instructions.
43 @item -warn-undocumented-instructions
45 Issue warnings for undocumented Z80-instructions that work on R800, do
46 not assemble other undocumented instructions without warning.
47 @item -warn-unportable-instructions
49 Issue warnings for other undocumented Z80-instructions, do not treat any
50 undocumented instructions as errors.
51 @item -forbid-undocumented-instructions
53 Treat all undocumented z80-instructions as errors.
54 @item -forbid-unportable-instructions
56 Treat undocumented z80-instructions that do not work on R800 as errors.
58 @cindex @code{-r800} command line option, Z80
60 Produce code for the R800 processor. The assembler does not support
61 undocumented instructions for the R800.
62 In line with common practice, @code{@value{AS}} uses Z80 instriction names
63 for the R800 processor, as far as they exist.
69 The assembler syntax closely follows the 'Z80 family CPU User Manual' by
71 In expressions a single @samp{=} may be used as ``is equal to''
74 Suffices can be used to indicate the radix of integer constants;
75 @samp{H} or @samp{h} for hexadecimal, @samp{D} or @samp{d} for decimal,
76 @samp{Q}, @samp{O}, @samp{q} or @samp{o} for octal, and @samp{B} for
79 The suffix @samp{b} denotes a backreference to local label.
82 * Z80-Chars:: Special Characters
83 * Z80-Regs:: Register Names
84 * Z80-Case:: Case Sensitivity
88 @subsection Special Characters
90 @cindex line comment character, Z80
91 @cindex Z80 line comment character
92 The semicolon @samp{;} is the line comment character;
94 @cindex location counter, Z80
95 @cindex hexadecimal prefix, Z80
97 The dollar sign @samp{$} can be used as a prefix for hexadecimal numbers
98 and as a symbol denoting the current location counter.
100 @cindex character escapes, Z80
102 A backslash @samp{\} is an ordinary character for the Z80 assembler.
104 @cindex character constant, Z80
105 @cindex single quote, Z80
107 The single quote @samp{'} must be followed by a closing quote. If there
108 is one character inbetween, it is a character constant, otherwise it is
112 @subsection Register Names
113 @cindex Z80 registers
114 @cindex register names, Z80
116 The registers are referred to with the letters assigned to them by
117 Zilog. In addition @command{@value{AS}} recognises @samp{ixl} and
118 @samp{ixh} as the least and most significant octet in @samp{ix}, and
119 similarly @samp{iyl} and @samp{iyh} as parts of @samp{iy}.
121 @c The @samp{'} in @samp{ex af,af'} may be omitted.
124 @subsection Case Sensitivity
125 @cindex Z80, case sensitivity
126 @cindex case sensitivity, Z80
128 Upper and lower case are equivalent in register names, opcodes,
129 condition codes and assembler directives.
130 The case of letters is significant in labels and symbol names. The case
131 is also important to distinguish the suffix @samp{b} for a backward reference
132 to a local label from the suffix @samp{B} for a number in binary notation.
134 @node Z80 Floating Point
135 @section Floating Point
136 @cindex floating point, Z80
137 @cindex Z80 floating point
138 Floating-point numbers are not supported.
141 @section Z80 Assembler Directives
143 @command{@value{AS}} for the Z80 supports some additional directives for
144 compatibility with other assemblers.
146 @cindex Z80-only directives
147 These are the additional directives in @code{@value{AS}} for the Z80:
150 @item db @var{expression}|@var{string}[,@var{expression}|@var{string}...]
151 @itemx defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]
152 For each @var{string} the characters are copied to the object file, for
153 each other @var{expression} the value is stored in one byte.
154 A warning is issued in case of an overflow.
156 @item dw @var{expression}[,@var{expression}...]
157 @itemx defw @var{expression}[,@var{expression}...]
158 For each @var{expression} the value is stored in two bytes, ignoring
161 @item d24 @var{expression}[,@var{expression}...]
162 @itemx def24 @var{expression}[,@var{expression}...]
163 For each @var{expression} the value is stored in three bytes, ignoring
166 @item d32 @var{expression}[,@var{expression}...]
167 @itemx def32 @var{expression}[,@var{expression}...]
168 For each @var{expression} the value is stored in four bytes, ignoring
171 @item ds @var{count}[, @var{value}]
172 @itemx defs @var{count}[, @var{value}]
173 @c Synonyms for @code{ds.b},
174 @c which should have been described elsewhre
175 Fill @var{count} bytes in the object file with @var{value}, if
176 @var{value} is omitted it defaults to zero.
178 @item @var{symbol} equ @var{expression}
179 @itemx @var{symbol} defl @var{expression}
180 These directives set the value of @var{symbol} to @var{expression}. If
181 @code{equ} is used, it is an error if @var{symbol} is already defined.
182 Symbols defined with @code{equ} are not protected from redefinition.
185 This is a normal instruction on Z80, and not an assembler directive.
187 @item psect @var{name}
188 A synonym for @xref{Section}, no second argument should be given.
191 The following attributes will possibly be recognised in the future
194 The section is to be absolute. @code{@value{AS}} will issue an error
195 message because it can not produce an absolute section.
197 The section is to be concatenated with other sections of the same name
198 by the linker, this is the default.
200 The section is not global. @code{@value{AS}} will issue a warning if
201 object file format is not soff.
203 The section is to be overlapped with other sections of the same name by
204 the linker. @code{@value{AS}} will issue an error message
205 because it can not mark a section as such.
207 The section is marked as read only.
215 In line with commmon practice Z80 mnonics are used for both the Z80 and
218 In many instructions it is possible to use one of the half index
219 registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
220 8-bit general purpose register. This yields instructions that are
221 documented on the R800 and undocumented on the Z80.
222 Similarly @code{in f,(c)} is documented on the R800 and undocumented on
225 The assembler also supports the following undocumented Z80-instructions,
226 that have not been adopted in the R800 instruction set:
229 Sends zero to the port pointed to by register c.
232 Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
233 be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
234 synonym for @samp{sli}.
236 @item @var{op} (ix+@var{d}), @var{r}
237 This is equivalent to
240 ld @var{r}, (ix+@var{d})
242 ld (ix+@var{d}), @var{r}
245 The operation @samp{@var{opc}} may be any of @samp{res @var{b},},
246 @samp{set @var{b},}, @samp{rl}, @samp{rlc}, @samp{rr}, @samp{rrc},
247 @samp{sla}, @samp{sli}, @samp{sra} and @samp{srl}, and the register
248 @samp{@var{r}} may be any of @samp{a}, @samp{b}, @samp{c}, @samp{d},
249 @samp{e}, @samp{h} and @samp{l}.
251 @item @var{opc} (iy+@var{d}), @var{r}
252 As above, but with @samp{iy} instead of @samp{ix}.
255 The web site at @uref{http://www.z80.info} is a good starting place to
256 find more information on programming the Z80.