gas/ acinclude.m4 aclocal.m4 app.c app.o as.c as.h as.h.cvs asintl.h as-new as.o...
[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
11 @ifclear GENERIC
12 @node Machine Dependencies
13 @chapter Z80 Dependent Features
14 @end ifclear
15
16 @cindex Z80 support
17 @menu
18 * Z80 Options:: Options
19 * Z80 Syntax:: Syntax
20 * Z80 Floating Point:: Floating Point
21 * Z80 Directives:: Z80 Machine Directives
22 * Z80 Opcodes:: Opcodes
23 @end menu
24
25 @node Z80 Options
26 @section Options
27 @cindex Z80 options
28 @cindex options for Z80
29 The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
30 dependent options.
31 @table @option
32 @cindex @code{-z80} command line option, Z80
33 @item -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
37 @itemx -Wnud
38 Silently assemble undocumented Z80-instructions that have been adopted
39 as documented R800-instructions.
40 @item -ignore-unportable-instructions
41 @itemx -Wnup
42 Silently assemble all undocumented Z80-instructions.
43 @item -warn-undocumented-instructions
44 @itemx -Wud
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
48 @itemx -Wup
49 Issue warnings for other undocumented Z80-instructions, do not treat any
50 undocumented instructions as errors.
51 @item -forbid-undocumented-instructions
52 @itemx -Fud
53 Treat all undocumented z80-instructions as errors.
54 @item -forbid-unportable-instructions
55 @itemx -Fup
56 Treat undocumented z80-instructions that do not work on R800 as errors.
57
58 @cindex @code{-r800} command line option, Z80
59 @item -r800
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.
64 @end table
65
66 @cindex Z80 Syntax
67 @node Z80 Syntax
68 @section Syntax
69 The assembler syntax closely follows the 'Z80 family CPU User Manual' by
70 Zilog.
71 In expressions a single @samp{=} may be used as ``is equal to''
72 comparison operator.
73
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
77 binary.
78
79 The suffix @samp{b} denotes a backreference to local label.
80
81 @menu
82 * Z80-Chars:: Special Characters
83 * Z80-Regs:: Register Names
84 * Z80-Case:: Case Sensitivity
85 @end menu
86
87 @node Z80-Chars
88 @subsection Special Characters
89
90 @cindex line comment character, Z80
91 @cindex Z80 line comment character
92 The semicolon @samp{;} is the line comment character;
93
94 @cindex location counter, Z80
95 @cindex hexadecimal prefix, Z80
96 @cindex 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.
99
100 @cindex character escapes, Z80
101 @cindex Z80, \
102 A backslash @samp{\} is an ordinary character for the Z80 assembler.
103
104 @cindex character constant, Z80
105 @cindex single quote, Z80
106 @cindex 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
109 a string constant.
110
111 @node Z80-Regs
112 @subsection Register Names
113 @cindex Z80 registers
114 @cindex register names, Z80
115
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}.
120
121 @c The @samp{'} in @samp{ex af,af'} may be omitted.
122
123 @node Z80-Case
124 @subsection Case Sensitivity
125 @cindex Z80, case sensitivity
126 @cindex case sensitivity, Z80
127
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.
133
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.
139
140 @node Z80 Directives
141 @section Z80 Assembler Directives
142
143 @command{@value{AS}} for the Z80 supports some additional directives for
144 compatibility with other assemblers.
145
146 @cindex Z80-only directives
147 These are the additional directives in @code{@value{AS}} for the Z80:
148
149 @table @code
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, ignoring
154 overflow.
155
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
159 overflow.
160
161 @item ds @var{count}[, @var{value}]
162 @itemx defs @var{count}[, @var{value}]
163 @c Synonyms for @code{ds.b},
164 @c which should have been described elsewhre
165 Fill @var{count} bytes in the object file with @var{value}, if
166 @var{value} is omitted it defaults to zero.
167
168 @item @var{symbol} equ @var{expression}
169 @itemx @var{symbol} defl @var{expression}
170 These directives set the value of @var{symbol} to @var{expression}. If
171 @code{equ} is used, it is an error if @var{symbol} is already defined.
172 Symbols defined with @code{equ} are not protected from redefinition.
173
174 @item set
175 This is a normal instruction on Z80, and not an assembler directive.
176
177 @item psect @var{name}
178 A synonym for @xref{Section}, no second argument should be given.
179 @ignore
180
181 The following attributes will possibly be recognised in the future
182 @table @code
183 @item abs
184 The section is to be absolute. @code{@value{AS}} will issue an error
185 message because it can not produce an absolute section.
186 @item global
187 The section is to be concatenated with other sections of the same name
188 by the linker, this is the default.
189 @item local
190 The section is not global. @code{@value{AS}} will issue a warning if
191 object file format is not soff.
192 @item ovrld
193 The section is to be overlapped with other sections of the same name by
194 the linker. @code{@value{AS}} will issue an error message
195 because it can not mark a section as such.
196 @item pure
197 The section is marked as read only.
198 @end table
199 @end ignore
200
201 @end table
202
203 @node Z80 Opcodes
204 @section Opcodes
205 In line with commmon practice Z80 mnonics are used for both the Z80 and
206 the R800.
207
208 In many instructions it is possible to use one of the half index
209 registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
210 8-bit general purpose register. This yields instructions that are
211 documented on the R800 and undocumented on the Z80.
212 Similarly @code{in f,(c)} is documented on the R800 and undocumented on
213 the Z80.
214
215 The assembler also supports the following undocumented Z80-instructions,
216 that have not been adopted in the R800 instruction set:
217 @table @code
218 @item out (c),0
219 Sends zero to the port pointed to by register c.
220
221 @item sli @var{m}
222 Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
223 be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
224 synonym for @samp{sli}.
225
226 @item @var{op} (ix+@var{d}), @var{r}
227 This is equivalent to
228
229 @example
230 ld @var{r}, (ix+@var{d})
231 @var{opc} @var{r}
232 ld (ix+@var{d}), @var{r}
233 @end example
234
235 The operation @samp{@var{opc}} may be any of @samp{res @var{b},},
236 @samp{set @var{b},}, @samp{rl}, @samp{rlc}, @samp{rr}, @samp{rrc},
237 @samp{sla}, @samp{sli}, @samp{sra} and @samp{srl}, and the register
238 @samp{@var{r}} may be any of @samp{a}, @samp{b}, @samp{c}, @samp{d},
239 @samp{e}, @samp{h} and @samp{l}.
240
241 @item @var{opc} (iy+@var{d}), @var{r}
242 As above, but with @samp{iy} instead of @samp{ix}.
243 @end table
244
245 The web site at @uref{http://www.z80.info} is a good starting place to
246 find more information on programming the Z80.
247
This page took 0.056709 seconds and 5 git commands to generate.