1 @c This is part of the GAS manual.
2 @c For copying conditions, see the file as.texinfo.
7 @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 instriction 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 @cindex location counter, Z80
96 @cindex hexadecimal prefix, Z80
98 The dollar sign @samp{$} can be used as a prefix for hexadecimal numbers
99 and as a symbol denoting the current location counter.
101 @cindex character escapes, Z80
103 A backslash @samp{\} is an ordinary character for the Z80 assembler.
105 @cindex character constant, Z80
106 @cindex single quote, Z80
108 The single quote @samp{'} must be followed by a closing quote. If there
109 is one character inbetween, it is a character constant, otherwise it is
113 @subsection Register Names
114 @cindex Z80 registers
115 @cindex register names, Z80
117 The registers are referred to with the letters assigned to them by
118 Zilog. In addition @command{@value{AS}} recognises @samp{ixl} and
119 @samp{ixh} as the least and most significant octet in @samp{ix}, and
120 similarly @samp{iyl} and @samp{iyh} as parts of @samp{iy}.
122 @c The @samp{'} in @samp{ex af,af'} may be omitted.
125 @subsection Case Sensitivity
126 @cindex Z80, case sensitivity
127 @cindex case sensitivity, Z80
129 Upper and lower case are equivalent in register names, opcodes,
130 condition codes and assembler directives.
131 The case of letters is significant in labels and symbol names. The case
132 is also important to distinguish the suffix @samp{b} for a backward reference
133 to a local label from the suffix @samp{B} for a number in binary notation.
135 @node Z80 Floating Point
136 @section Floating Point
137 @cindex floating point, Z80
138 @cindex Z80 floating point
139 Floating-point numbers are not supported.
142 @section Z80 Assembler Directives
144 @command{@value{AS}} for the Z80 supports some additional directives for
145 compatibility with other assemblers.
147 @cindex Z80-only directives
148 These are the additional directives in @code{@value{AS}} for the Z80:
151 @item db @var{expression}|@var{string}[,@var{expression}|@var{string}...]
152 @itemx defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]
153 For each @var{string} the characters are copied to the object file, for
154 each other @var{expression} the value is stored in one byte, ignoring
157 @item dw @var{expression}[,@var{expression}...]
158 @itemx defw @var{expression}[,@var{expression}...]
159 For each @var{expression} the value is stored in two bytes, ignoring
162 @item ds @var{count}[, @var{value}]
163 @itemx defs @var{count}[, @var{value}]
164 @c Synonyms for @code{ds.b},
165 @c which should have been described elsewhre
166 Fill @var{count} bytes in the object file with @var{value}, if
167 @var{value} is omitted it defaults to zero.
169 @item @var{symbol} equ @var{expression}
170 @itemx @var{symbol} defl @var{expression}
171 These directives set the value of @var{symbol} to @var{expression}. To
172 keep code portable to other assemblers it is best to use @samp{equ} for
173 the first definition and @samp{defl} for redefinitions.
176 This is a normal instruction on Z80, and not an assembler directive.
178 @item psect @var{name}
179 A synonym for @xref{Section}, no second argument should be given.
182 The following attributes will possibly be recognised in the future
185 The section is to be absolute. @code{@value{AS}} will issue an error
186 message because it can not produce an absolute section.
188 The section is to be concatenated with other sections of the same name
189 by the linker, this is the default.
191 The section is not global. @code{@value{AS}} will issue a warning if
192 object file format is not soff.
194 The section is to be overlapped with other sections of the same name by
195 the linker. @code{@value{AS}} will issue an error message
196 because it can not mark a section as such.
198 The section is marked as read only.
206 In line with commmon practice Z80 mnonics are used for both the Z80 and
209 In many instructions it is possible to use one of the half index
210 registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
211 8-bit general purpose register. This yields instructions that are
212 documented on the R800 and undocumented on the Z80.
213 Similarly @code{in f,(c)} is documented on the R800 and undocumented on
216 The assembler also supports the following undocumented Z80-instructions,
217 that have not been adopted in the R800 instruction set:
220 Sends zero to the port pointed to by register c.
223 Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
224 be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
225 synonym for @samp{sli}.
227 @item @var{op} (ix+@var{d}), @var{r}
228 This is equivalent to
231 ld @var{r}, (ix+@var{d})
233 ld (ix+@var{d}), @var{r}
236 The operation @samp{@var{opc}} may be any of @samp{res @var{b},},
237 @samp{set @var{b},}, @samp{rl}, @samp{rlc}, @samp{rr}, @samp{rrc},
238 @samp{sla}, @samp{sli}, @samp{sra} and @samp{srl}, and the register
239 @samp{@var{r}} may be any of @samp{a}, @samp{b}, @samp{c}, @samp{d},
240 @samp{e}, @samp{h} and @samp{l}.
242 @item @var{opc} (iy+@var{d}), @var{r}
243 As above, but with @samp{iy} instead of @samp{ix}.
246 The web site at @uref{http://www.z80.info} is a good starting place to
247 find more information on programming the Z80.