Import binutils-2.20
[dragonfly.git] / contrib / binutils-2.20 / gas / doc / c-z80.texi
CommitLineData
8e158dd0
SS
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
29The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
30dependent options.
31@table @option
32@cindex @code{-z80} command line option, Z80
33@item -z80
34Produce code for the Z80 processor. There are additional options to
35request warnings and error messages for undocumented instructions.
36@item -ignore-undocumented-instructions
37@itemx -Wnud
38Silently assemble undocumented Z80-instructions that have been adopted
39as documented R800-instructions.
40@item -ignore-unportable-instructions
41@itemx -Wnup
42Silently assemble all undocumented Z80-instructions.
43@item -warn-undocumented-instructions
44@itemx -Wud
45Issue warnings for undocumented Z80-instructions that work on R800, do
46not assemble other undocumented instructions without warning.
47@item -warn-unportable-instructions
48@itemx -Wup
49Issue warnings for other undocumented Z80-instructions, do not treat any
50undocumented instructions as errors.
51@item -forbid-undocumented-instructions
52@itemx -Fud
53Treat all undocumented z80-instructions as errors.
54@item -forbid-unportable-instructions
55@itemx -Fup
56Treat undocumented z80-instructions that do not work on R800 as errors.
57
58@cindex @code{-r800} command line option, Z80
59@item -r800
60Produce code for the R800 processor. The assembler does not support
61undocumented instructions for the R800.
62In line with common practice, @code{@value{AS}} uses Z80 instruction names
63for the R800 processor, as far as they exist.
64@end table
65
66@cindex Z80 Syntax
67@node Z80 Syntax
68@section Syntax
69The assembler syntax closely follows the 'Z80 family CPU User Manual' by
70Zilog.
71In expressions a single @samp{=} may be used as ``is equal to''
72comparison operator.
73
74Suffices 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
77binary.
78
79The 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
92The semicolon @samp{;} is the line comment character;
93
94@cindex location counter, Z80
95@cindex hexadecimal prefix, Z80
96@cindex Z80 $
97The dollar sign @samp{$} can be used as a prefix for hexadecimal numbers
98and as a symbol denoting the current location counter.
99
100@cindex character escapes, Z80
101@cindex Z80, \
102A backslash @samp{\} is an ordinary character for the Z80 assembler.
103
104@cindex character constant, Z80
105@cindex single quote, Z80
106@cindex Z80 '
107The single quote @samp{'} must be followed by a closing quote. If there
108is one character in between, it is a character constant, otherwise it is
109a string constant.
110
111@node Z80-Regs
112@subsection Register Names
113@cindex Z80 registers
114@cindex register names, Z80
115
116The registers are referred to with the letters assigned to them by
117Zilog. In addition @command{@value{AS}} recognizes @samp{ixl} and
118@samp{ixh} as the least and most significant octet in @samp{ix}, and
119similarly @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
128Upper and lower case are equivalent in register names, opcodes,
129condition codes and assembler directives.
130The case of letters is significant in labels and symbol names. The case
131is also important to distinguish the suffix @samp{b} for a backward reference
132to 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
138Floating-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
144compatibility with other assemblers.
145
146@cindex Z80-only directives
147These 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}...]
152For each @var{string} the characters are copied to the object file, for
153each other @var{expression} the value is stored in one byte.
154A warning is issued in case of an overflow.
155
156@item dw @var{expression}[,@var{expression}...]
157@itemx defw @var{expression}[,@var{expression}...]
158For each @var{expression} the value is stored in two bytes, ignoring
159overflow.
160
161@item d24 @var{expression}[,@var{expression}...]
162@itemx def24 @var{expression}[,@var{expression}...]
163For each @var{expression} the value is stored in three bytes, ignoring
164overflow.
165
166@item d32 @var{expression}[,@var{expression}...]
167@itemx def32 @var{expression}[,@var{expression}...]
168For each @var{expression} the value is stored in four bytes, ignoring
169overflow.
170
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 elsewhere
175Fill @var{count} bytes in the object file with @var{value}, if
176@var{value} is omitted it defaults to zero.
177
178@item @var{symbol} equ @var{expression}
179@itemx @var{symbol} defl @var{expression}
180These 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.
182Symbols defined with @code{equ} are not protected from redefinition.
183
184@item set
185This is a normal instruction on Z80, and not an assembler directive.
186
187@item psect @var{name}
188A synonym for @xref{Section}, no second argument should be given.
189@ignore
190
191The following attributes will possibly be recognized in the future
192@table @code
193@item abs
194The section is to be absolute. @code{@value{AS}} will issue an error
195message because it can not produce an absolute section.
196@item global
197The section is to be concatenated with other sections of the same name
198by the linker, this is the default.
199@item local
200The section is not global. @code{@value{AS}} will issue a warning if
201object file format is not soff.
202@item ovrld
203The section is to be overlapped with other sections of the same name by
204the linker. @code{@value{AS}} will issue an error message
205because it can not mark a section as such.
206@item pure
207The section is marked as read only.
208@end table
209@end ignore
210
211@end table
212
213@node Z80 Opcodes
214@section Opcodes
215In line with common practice, Z80 mnemonics are used for both the Z80 and
216the R800.
217
218In many instructions it is possible to use one of the half index
219registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
2208-bit general purpose register. This yields instructions that are
221documented on the R800 and undocumented on the Z80.
222Similarly @code{in f,(c)} is documented on the R800 and undocumented on
223the Z80.
224
225The assembler also supports the following undocumented Z80-instructions,
226that have not been adopted in the R800 instruction set:
227@table @code
228@item out (c),0
229Sends zero to the port pointed to by register c.
230
231@item sli @var{m}
232Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
233be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
234synonym for @samp{sli}.
235
236@item @var{op} (ix+@var{d}), @var{r}
237This is equivalent to
238
239@example
240ld @var{r}, (ix+@var{d})
241@var{opc} @var{r}
242ld (ix+@var{d}), @var{r}
243@end example
244
245The 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}.
250
251@item @var{opc} (iy+@var{d}), @var{r}
252As above, but with @samp{iy} instead of @samp{ix}.
253@end table
254
255The web site at @uref{http://www.z80.info} is a good starting place to
256find more information on programming the Z80.
257