Add support for the Z80 processor family
[deliverable/binutils-gdb.git] / gas / doc / c-z80.texi
1 @c This is part of the GAS manual.
2 @c For copying conditions, see the file as.texinfo.
3
4 @ifset GENERIC
5 @page
6 @node Z80-Dependent
7 @chapter Z80 Dependent Features
8 @end ifset
9
10 @c DO-NOT-COMMIT
11
12 @ifclear GENERIC
13 @node Machine Dependencies
14 @chapter Z80 Dependent Features
15 @end ifclear
16
17 @cindex Z80 support
18 @menu
19 * Z80 Options:: Options
20 * Z80 Syntax:: Syntax
21 * Z80 Floating Point:: Floating Point
22 * Z80 Directives:: Z80 Machine Directives
23 * Z80 Opcodes:: Opcodes
24 @end menu
25
26 @node Z80 Options
27 @section Options
28 @cindex Z80 options
29 @cindex options for Z80
30 The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
31 dependent options.
32 @table @option
33 @cindex @code{-z80} command line option, Z80
34 @item -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
38 @itemx -Wnud
39 Silently assemble undocumented Z80-instructions that have been adopted
40 as documented R800-instructions.
41 @item -ignore-unportable-instructions
42 @itemx -Wnup
43 Silently assemble all undocumented Z80-instructions.
44 @item -warn-undocumented-instructions
45 @itemx -Wud
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
49 @itemx -Wup
50 Issue warnings for other undocumented Z80-instructions, do not treat any
51 undocumented instructions as errors.
52 @item -forbid-undocumented-instructions
53 @itemx -Fud
54 Treat all undocumented z80-instructions as errors.
55 @item -forbid-unportable-instructions
56 @itemx -Fup
57 Treat undocumented z80-instructions that do not work on R800 as errors.
58
59 @cindex @code{-r800} command line option, Z80
60 @item -r800
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.
65 @end table
66
67 @cindex Z80 Syntax
68 @node Z80 Syntax
69 @section Syntax
70 The assembler syntax closely follows the 'Z80 family CPU User Manual' by
71 Zilog.
72 In expressions a single @samp{=} may be used as ``is equal to''
73 comparison operator.
74
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
78 binary.
79
80 The suffix @samp{b} denotes a backreference to local label.
81
82 @menu
83 * Z80-Chars:: Special Characters
84 * Z80-Regs:: Register Names
85 * Z80-Case:: Case Sensitivity
86 @end menu
87
88 @node Z80-Chars
89 @subsection Special Characters
90
91 @cindex line comment character, Z80
92 @cindex Z80 line comment character
93 The semicolon @samp{;} is the line comment character;
94
95 @cindex location counter, Z80
96 @cindex hexadecimal prefix, Z80
97 @cindex 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.
100
101 @cindex character escapes, Z80
102 @cindex Z80, \
103 A backslash @samp{\} is an ordinary character for the Z80 assembler.
104
105 @cindex character constant, Z80
106 @cindex single quote, Z80
107 @cindex 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
110 a string constant.
111
112 @node Z80-Regs
113 @subsection Register Names
114 @cindex Z80 registers
115 @cindex register names, Z80
116
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}.
121
122 @c The @samp{'} in @samp{ex af,af'} may be omitted.
123
124 @node Z80-Case
125 @subsection Case Sensitivity
126 @cindex Z80, case sensitivity
127 @cindex case sensitivity, Z80
128
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.
134
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.
140
141 @node Z80 Directives
142 @section Z80 Assembler Directives
143
144 @command{@value{AS}} for the Z80 supports some additional directives for
145 compatibility with other assemblers.
146
147 @cindex Z80-only directives
148 These are the additional directives in @code{@value{AS}} for the Z80:
149
150 @table @code
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
155 overflow.
156
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
160 overflow.
161
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.
168
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.
174
175 @item set
176 This is a normal instruction on Z80, and not an assembler directive.
177
178 @item psect @var{name}
179 A synonym for @xref{Section}, no second argument should be given.
180 @ignore
181
182 The following attributes will possibly be recognised in the future
183 @table @code
184 @item abs
185 The section is to be absolute. @code{@value{AS}} will issue an error
186 message because it can not produce an absolute section.
187 @item global
188 The section is to be concatenated with other sections of the same name
189 by the linker, this is the default.
190 @item local
191 The section is not global. @code{@value{AS}} will issue a warning if
192 object file format is not soff.
193 @item ovrld
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.
197 @item pure
198 The section is marked as read only.
199 @end table
200 @end ignore
201
202 @end table
203
204 @node Z80 Opcodes
205 @section Opcodes
206 In line with commmon practice Z80 mnonics are used for both the Z80 and
207 the R800.
208
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
214 the Z80.
215
216 The assembler also supports the following undocumented Z80-instructions,
217 that have not been adopted in the R800 instruction set:
218 @table @code
219 @item out (c),0
220 Sends zero to the port pointed to by register c.
221
222 @item sli @var{m}
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}.
226
227 @item @var{op} (ix+@var{d}), @var{r}
228 This is equivalent to
229
230 @example
231 ld @var{r}, (ix+@var{d})
232 @var{opc} @var{r}
233 ld (ix+@var{d}), @var{r}
234 @end example
235
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}.
241
242 @item @var{opc} (iy+@var{d}), @var{r}
243 As above, but with @samp{iy} instead of @samp{ix}.
244 @end table
245
246 The web site at @uref{http://www.z80.info} is a good starting place to
247 find more information on programming the Z80.
248
This page took 0.035203 seconds and 4 git commands to generate.