1 @c Copyright 2011 Free Software Foundation, Inc.
2 @c This is part of the GAS manual.
3 @c For copying conditions, see the file as.texinfo.
8 @chapter Z80 Dependent Features
13 @node Machine Dependencies
14 @chapter Z80 Dependent Features
19 * Z80 Options:: Options
21 * Z80 Floating Point:: Floating Point
22 * Z80 Directives:: Z80 Machine Directives
23 * Z80 Opcodes:: Opcodes
29 @cindex options for Z80
30 The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
33 @cindex @code{-z80} command line option, Z80
35 Produce code for the Z80 processor. There are additional options to
36 request warnings and error messages for undocumented instructions.
37 @item -ignore-undocumented-instructions
39 Silently assemble undocumented Z80-instructions that have been adopted
40 as documented R800-instructions.
41 @item -ignore-unportable-instructions
43 Silently assemble all undocumented Z80-instructions.
44 @item -warn-undocumented-instructions
46 Issue warnings for undocumented Z80-instructions that work on R800, do
47 not assemble other undocumented instructions without warning.
48 @item -warn-unportable-instructions
50 Issue warnings for other undocumented Z80-instructions, do not treat any
51 undocumented instructions as errors.
52 @item -forbid-undocumented-instructions
54 Treat all undocumented z80-instructions as errors.
55 @item -forbid-unportable-instructions
57 Treat undocumented z80-instructions that do not work on R800 as errors.
59 @cindex @code{-r800} command line option, Z80
61 Produce code for the R800 processor. The assembler does not support
62 undocumented instructions for the R800.
63 In line with common practice, @code{@value{AS}} uses Z80 instruction names
64 for the R800 processor, as far as they exist.
70 The assembler syntax closely follows the 'Z80 family CPU User Manual' by
72 In expressions a single @samp{=} may be used as ``is equal to''
75 Suffices can be used to indicate the radix of integer constants;
76 @samp{H} or @samp{h} for hexadecimal, @samp{D} or @samp{d} for decimal,
77 @samp{Q}, @samp{O}, @samp{q} or @samp{o} for octal, and @samp{B} for
80 The suffix @samp{b} denotes a backreference to local label.
83 * Z80-Chars:: Special Characters
84 * Z80-Regs:: Register Names
85 * Z80-Case:: Case Sensitivity
89 @subsection Special Characters
91 @cindex line comment character, Z80
92 @cindex Z80 line comment character
93 The semicolon @samp{;} is the line comment character;
95 If a @samp{#} appears as the first character of a line then the whole
96 line is treated as a comment, but in this case the line could also be
97 a logical line number directive (@pxref{Comments}) or a preprocessor
98 control command (@pxref{Preprocessing}).
100 @cindex line separator, Z80
101 @cindex statement separator, Z80
102 @cindex Z80 line separator
103 The Z80 assembler does not support a line separator character.
105 @cindex location counter, Z80
106 @cindex hexadecimal prefix, Z80
108 The dollar sign @samp{$} can be used as a prefix for hexadecimal numbers
109 and as a symbol denoting the current location counter.
111 @cindex character escapes, Z80
113 A backslash @samp{\} is an ordinary character for the Z80 assembler.
115 @cindex character constant, Z80
116 @cindex single quote, Z80
118 The single quote @samp{'} must be followed by a closing quote. If there
119 is one character in between, it is a character constant, otherwise it is
123 @subsection Register Names
124 @cindex Z80 registers
125 @cindex register names, Z80
127 The registers are referred to with the letters assigned to them by
128 Zilog. In addition @command{@value{AS}} recognizes @samp{ixl} and
129 @samp{ixh} as the least and most significant octet in @samp{ix}, and
130 similarly @samp{iyl} and @samp{iyh} as parts of @samp{iy}.
132 @c The @samp{'} in @samp{ex af,af'} may be omitted.
135 @subsection Case Sensitivity
136 @cindex Z80, case sensitivity
137 @cindex case sensitivity, Z80
139 Upper and lower case are equivalent in register names, opcodes,
140 condition codes and assembler directives.
141 The case of letters is significant in labels and symbol names. The case
142 is also important to distinguish the suffix @samp{b} for a backward reference
143 to a local label from the suffix @samp{B} for a number in binary notation.
145 @node Z80 Floating Point
146 @section Floating Point
147 @cindex floating point, Z80
148 @cindex Z80 floating point
149 Floating-point numbers are not supported.
152 @section Z80 Assembler Directives
154 @command{@value{AS}} for the Z80 supports some additional directives for
155 compatibility with other assemblers.
157 @cindex Z80-only directives
158 These are the additional directives in @code{@value{AS}} for the Z80:
161 @item db @var{expression}|@var{string}[,@var{expression}|@var{string}...]
162 @itemx defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]
163 For each @var{string} the characters are copied to the object file, for
164 each other @var{expression} the value is stored in one byte.
165 A warning is issued in case of an overflow.
167 @item dw @var{expression}[,@var{expression}...]
168 @itemx defw @var{expression}[,@var{expression}...]
169 For each @var{expression} the value is stored in two bytes, ignoring
172 @item d24 @var{expression}[,@var{expression}...]
173 @itemx def24 @var{expression}[,@var{expression}...]
174 For each @var{expression} the value is stored in three bytes, ignoring
177 @item d32 @var{expression}[,@var{expression}...]
178 @itemx def32 @var{expression}[,@var{expression}...]
179 For each @var{expression} the value is stored in four bytes, ignoring
182 @item ds @var{count}[, @var{value}]
183 @itemx defs @var{count}[, @var{value}]
184 @c Synonyms for @code{ds.b},
185 @c which should have been described elsewhere
186 Fill @var{count} bytes in the object file with @var{value}, if
187 @var{value} is omitted it defaults to zero.
189 @item @var{symbol} equ @var{expression}
190 @itemx @var{symbol} defl @var{expression}
191 These directives set the value of @var{symbol} to @var{expression}. If
192 @code{equ} is used, it is an error if @var{symbol} is already defined.
193 Symbols defined with @code{equ} are not protected from redefinition.
196 This is a normal instruction on Z80, and not an assembler directive.
198 @item psect @var{name}
199 A synonym for @xref{Section}, no second argument should be given.
202 The following attributes will possibly be recognized in the future
205 The section is to be absolute. @code{@value{AS}} will issue an error
206 message because it can not produce an absolute section.
208 The section is to be concatenated with other sections of the same name
209 by the linker, this is the default.
211 The section is not global. @code{@value{AS}} will issue a warning if
212 object file format is not soff.
214 The section is to be overlapped with other sections of the same name by
215 the linker. @code{@value{AS}} will issue an error message
216 because it can not mark a section as such.
218 The section is marked as read only.
226 In line with common practice, Z80 mnemonics are used for both the Z80 and
229 In many instructions it is possible to use one of the half index
230 registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
231 8-bit general purpose register. This yields instructions that are
232 documented on the R800 and undocumented on the Z80.
233 Similarly @code{in f,(c)} is documented on the R800 and undocumented on
236 The assembler also supports the following undocumented Z80-instructions,
237 that have not been adopted in the R800 instruction set:
240 Sends zero to the port pointed to by register c.
243 Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
244 be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
245 synonym for @samp{sli}.
247 @item @var{op} (ix+@var{d}), @var{r}
248 This is equivalent to
251 ld @var{r}, (ix+@var{d})
253 ld (ix+@var{d}), @var{r}
256 The operation @samp{@var{opc}} may be any of @samp{res @var{b},},
257 @samp{set @var{b},}, @samp{rl}, @samp{rlc}, @samp{rr}, @samp{rrc},
258 @samp{sla}, @samp{sli}, @samp{sra} and @samp{srl}, and the register
259 @samp{@var{r}} may be any of @samp{a}, @samp{b}, @samp{c}, @samp{d},
260 @samp{e}, @samp{h} and @samp{l}.
262 @item @var{opc} (iy+@var{d}), @var{r}
263 As above, but with @samp{iy} instead of @samp{ix}.
266 The web site at @uref{http://www.z80.info} is a good starting place to
267 find more information on programming the Z80.