RISC-V: Support assembler modifier %got_pcrel_hi.
[deliverable/binutils-gdb.git] / gas / doc / c-z80.texi
CommitLineData
b3adc24a 1@c Copyright (C) 2011-2020 Free Software Foundation, Inc.
3c9b82ba
NC
2@c This is part of the GAS manual.
3@c For copying conditions, see the file as.texinfo.
4
5@ifset GENERIC
6@page
7@node Z80-Dependent
8@chapter Z80 Dependent Features
9@end ifset
10
3c9b82ba
NC
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
7a6bf3be 27@section Command-line Options
3c9b82ba
NC
28@cindex Z80 options
29@cindex options for Z80
7a6bf3be
SB
30@c man begin OPTIONS
31@table @gcctabopt
fcaaac0a
SB
32
33@cindex @samp{-march=} option, Z80
34@item -march=@var{CPU}[-@var{EXT}@dots{}][+@var{EXT}@dots{}]
35This option specifies the target processor. The assembler will issue
36an error message if an attempt is made to assemble an instruction which
37will not execute on the target processor. The following processor names
38are recognized:
39@code{z80},
40@code{z180},
41@code{ez80},
42@code{gbz80},
43@code{z80n},
44@code{r800}.
45In addition to the basic instruction set, the assembler can be told to
46accept some extention mnemonics. For example,
47@code{-march=z180+sli+infc} extends @var{z180} with @var{SLI} instructions and
48@var{IN F,(C)}. The following instructions are currently supported:
49@code{full} (all known instructions),
50@code{adl} (ADL CPU mode by default),
51@code{sli} (instruction known as @var{SLI}, @var{SLL} or @var{SL1}),
52@code{xyhl} (instructions with halves of index registers: @var{IXL}, @var{IXH},
53@var{IYL}, @var{IYH}),
54@code{xdcb} (instructions like @var{RotOp (II+d),R} and @var{BitOp n,(II+d),R}),
55@code{infc} (instruction @var{IN F,(C)} or @var{IN (C)}),
56@code{outc0} (instruction @var{OUT (C),0}).
57Note that rather than extending a basic instruction set, the extention
58mnemonics starting with @code{-} revoke the respective functionality:
59@code{-march=z80-full+xyhl} first removes all default extentions and adds
60support for index registers halves only.
9fc0b501 61
7a6bf3be
SB
62@cindex @code{-local-prefix} command-line option, Z80
63@item -local-prefix=@var{prefix}
64Mark all labels with specified prefix as local. But such label can be
65marked global explicitly in the code. This option do not change default
66local label prefix @code{.L}, it is just adds new one.
67
68@cindex @code{-colonless} command-line option, Z80
69@item -colonless
6655dba2
SB
70Accept colonless labels. All names at line begin are treated as labels.
71
7a6bf3be
SB
72@cindex @code{-sdcc} command-line option, Z80
73@item -sdcc
74Accept assembler code produced by SDCC.
75
76@cindex @code{-fp-s} command-line option, Z80
77@item -fp-s=@var{FORMAT}
78Single precision floating point numbers format. Default: ieee754 (32 bit).
6655dba2 79
7a6bf3be
SB
80@cindex @code{-fp-d} command-line option, Z80
81@item -fp-d=@var{FORMAT}
82Double precision floating point numbers format. Default: ieee754 (64 bit).
6655dba2 83@end table
7a6bf3be
SB
84@c man end
85
86Floating point numbers formats.
87@table @option
88@item @code{ieee754}
89Single or double precision IEEE754 compatible format.
90
91@item @code{half}
92Half precision IEEE754 compatible format (16 bits).
93
94@item @code{single}
95Single precision IEEE754 compatible format (32 bits).
96
97@item @code{double}
98Double precision IEEE754 compatible format (64 bits).
99
100@item @code{zeda32}
10132 bit floating point format from z80float library by Zeda.
102
103@item @code{math48}
10448 bit floating point format from Math48 package by Anders Hejlsberg.
105@end table
3c9b82ba 106
3c9b82ba
NC
107@cindex Z80 Syntax
108@node Z80 Syntax
109@section Syntax
110The assembler syntax closely follows the 'Z80 family CPU User Manual' by
111Zilog.
112In expressions a single @samp{=} may be used as ``is equal to''
34bca508 113comparison operator.
3c9b82ba
NC
114
115Suffices can be used to indicate the radix of integer constants;
116@samp{H} or @samp{h} for hexadecimal, @samp{D} or @samp{d} for decimal,
117@samp{Q}, @samp{O}, @samp{q} or @samp{o} for octal, and @samp{B} for
118binary.
119
34bca508 120The suffix @samp{b} denotes a backreference to local label.
3c9b82ba
NC
121
122@menu
123* Z80-Chars:: Special Characters
124* Z80-Regs:: Register Names
125* Z80-Case:: Case Sensitivity
7a6bf3be 126* Z80-Labels:: Labels
3c9b82ba
NC
127@end menu
128
129@node Z80-Chars
130@subsection Special Characters
131
132@cindex line comment character, Z80
133@cindex Z80 line comment character
34bca508 134The semicolon @samp{;} is the line comment character;
3c9b82ba 135
7c31ae13
NC
136If a @samp{#} appears as the first character of a line then the whole
137line is treated as a comment, but in this case the line could also be
138a logical line number directive (@pxref{Comments}) or a preprocessor
139control command (@pxref{Preprocessing}).
140
141@cindex line separator, Z80
142@cindex statement separator, Z80
143@cindex Z80 line separator
144The Z80 assembler does not support a line separator character.
145
3c9b82ba
NC
146@cindex location counter, Z80
147@cindex hexadecimal prefix, Z80
148@cindex Z80 $
149The dollar sign @samp{$} can be used as a prefix for hexadecimal numbers
150and as a symbol denoting the current location counter.
151
152@cindex character escapes, Z80
153@cindex Z80, \
154A backslash @samp{\} is an ordinary character for the Z80 assembler.
34bca508 155
3c9b82ba
NC
156@cindex character constant, Z80
157@cindex single quote, Z80
158@cindex Z80 '
159The single quote @samp{'} must be followed by a closing quote. If there
b45619c0 160is one character in between, it is a character constant, otherwise it is
3c9b82ba
NC
161a string constant.
162
163@node Z80-Regs
164@subsection Register Names
165@cindex Z80 registers
166@cindex register names, Z80
167
168The registers are referred to with the letters assigned to them by
34bca508 169Zilog. In addition @command{@value{AS}} recognizes @samp{ixl} and
3c9b82ba 170@samp{ixh} as the least and most significant octet in @samp{ix}, and
34bca508 171similarly @samp{iyl} and @samp{iyh} as parts of @samp{iy}.
3c9b82ba
NC
172
173@c The @samp{'} in @samp{ex af,af'} may be omitted.
174
175@node Z80-Case
176@subsection Case Sensitivity
177@cindex Z80, case sensitivity
178@cindex case sensitivity, Z80
179
180Upper and lower case are equivalent in register names, opcodes,
34bca508 181condition codes and assembler directives.
3c9b82ba
NC
182The case of letters is significant in labels and symbol names. The case
183is also important to distinguish the suffix @samp{b} for a backward reference
184to a local label from the suffix @samp{B} for a number in binary notation.
185
7a6bf3be
SB
186@node Z80-Labels
187@subsection Labels
188
189@cindex labels, Z80
190@cindex Z80 labels
191Labels started by @code{.L} acts as local labels. You may specify custom local
192label prefix by @code{-local-prefix} command-line option.
193Dollar, forward and backward local labels are supported. By default, all labels
194are followed by colon.
195Legacy code with colonless labels can be built with @code{-colonless}
196command-line option specified. In this case all tokens at line begin are treated
197as labels.
198
3c9b82ba
NC
199@node Z80 Floating Point
200@section Floating Point
201@cindex floating point, Z80
202@cindex Z80 floating point
7a6bf3be
SB
203Floating-point numbers of following types are supported:
204
205@table @option
206@item @code{ieee754}
207Supported half, single and double precision IEEE754 compatible numbers.
208
209@item @code{zeda32}
21032 bit floating point numbers from z80float library by Zeda.
211
212@item @code{math48}
21348 bit floating point numbers from Math48 package by Anders Hejlsberg.
214@end table
3c9b82ba
NC
215
216@node Z80 Directives
217@section Z80 Assembler Directives
218
219@command{@value{AS}} for the Z80 supports some additional directives for
34bca508 220compatibility with other assemblers.
3c9b82ba
NC
221
222@cindex Z80-only directives
223These are the additional directives in @code{@value{AS}} for the Z80:
224
225@table @code
6655dba2 226@item assume @var{ADL}@samp{=}@var{expression}
7a6bf3be 227Set ADL status for eZ80. Non-zero value enable compilation in ADL mode else
6655dba2
SB
228used Z80 mode. ADL and Z80 mode produces incompatible object code. Mixing
229both of them within one binary may lead problems with disassembler.
230
3c9b82ba
NC
231@item db @var{expression}|@var{string}[,@var{expression}|@var{string}...]
232@itemx defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]
7a6bf3be 233@itemx defm @var{string}...]
3c9b82ba 234For each @var{string} the characters are copied to the object file, for
34bca508
L
235each other @var{expression} the value is stored in one byte.
236A warning is issued in case of an overflow.
7a6bf3be
SB
237Backslash symbol in the strings is generic symbol, it cannot be used as
238escape character (for this purpose use @code{.ascii} or @code{.asciiz}
239directives).
3c9b82ba
NC
240
241@item dw @var{expression}[,@var{expression}...]
242@itemx defw @var{expression}[,@var{expression}...]
243For each @var{expression} the value is stored in two bytes, ignoring
34bca508 244overflow.
3c9b82ba 245
134dcee5
AM
246@item d24 @var{expression}[,@var{expression}...]
247@itemx def24 @var{expression}[,@var{expression}...]
248For each @var{expression} the value is stored in three bytes, ignoring
34bca508 249overflow.
134dcee5
AM
250
251@item d32 @var{expression}[,@var{expression}...]
252@itemx def32 @var{expression}[,@var{expression}...]
253For each @var{expression} the value is stored in four bytes, ignoring
34bca508 254overflow.
134dcee5 255
3c9b82ba
NC
256@item ds @var{count}[, @var{value}]
257@itemx defs @var{count}[, @var{value}]
34bca508 258@c Synonyms for @code{ds.b},
b45619c0 259@c which should have been described elsewhere
3c9b82ba
NC
260Fill @var{count} bytes in the object file with @var{value}, if
261@var{value} is omitted it defaults to zero.
262
263@item @var{symbol} equ @var{expression}
264@itemx @var{symbol} defl @var{expression}
f9eb6721
AM
265These directives set the value of @var{symbol} to @var{expression}. If
266@code{equ} is used, it is an error if @var{symbol} is already defined.
267Symbols defined with @code{equ} are not protected from redefinition.
3c9b82ba 268
3c9b82ba 269@item psect @var{name}
34bca508 270A synonym for @xref{Section}, no second argument should be given.
3c9b82ba
NC
271@ignore
272
b45619c0 273The following attributes will possibly be recognized in the future
3c9b82ba
NC
274@table @code
275@item abs
276The section is to be absolute. @code{@value{AS}} will issue an error
277message because it can not produce an absolute section.
278@item global
279The section is to be concatenated with other sections of the same name
280by the linker, this is the default.
281@item local
282The section is not global. @code{@value{AS}} will issue a warning if
283object file format is not soff.
284@item ovrld
285The section is to be overlapped with other sections of the same name by
286the linker. @code{@value{AS}} will issue an error message
287because it can not mark a section as such.
288@item pure
289The section is marked as read only.
290@end table
291@end ignore
292
293@end table
294
295@node Z80 Opcodes
296@section Opcodes
6655dba2 297In line with common practice, Z80 mnemonics are used for the Z80,
fcaaac0a 298Z80N, Z180, eZ80, Ascii R800 and the GameBoy Z80.
3c9b82ba
NC
299
300In many instructions it is possible to use one of the half index
301registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
3028-bit general purpose register. This yields instructions that are
6655dba2
SB
303documented on the eZ80 and the R800, undocumented on the Z80 and
304unsupported on the Z180.
305Similarly @code{in f,(c)} is documented on the R800, undocumented on
306the Z80 and unsupported on the Z180 and the eZ80.
3c9b82ba
NC
307
308The assembler also supports the following undocumented Z80-instructions,
6655dba2 309that have not been adopted in any other instruction set:
3c9b82ba
NC
310@table @code
311@item out (c),0
7a6bf3be 312Sends zero to the port pointed to by register @code{C}.
3c9b82ba
NC
313
314@item sli @var{m}
315Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
316be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
317synonym for @samp{sli}.
318
319@item @var{op} (ix+@var{d}), @var{r}
34bca508 320This is equivalent to
3c9b82ba
NC
321
322@example
323ld @var{r}, (ix+@var{d})
fcaaac0a 324@var{op} @var{r}
3c9b82ba
NC
325ld (ix+@var{d}), @var{r}
326@end example
327
fcaaac0a 328The operation @samp{@var{op}} may be any of @samp{res @var{b},},
3c9b82ba
NC
329@samp{set @var{b},}, @samp{rl}, @samp{rlc}, @samp{rr}, @samp{rrc},
330@samp{sla}, @samp{sli}, @samp{sra} and @samp{srl}, and the register
331@samp{@var{r}} may be any of @samp{a}, @samp{b}, @samp{c}, @samp{d},
332@samp{e}, @samp{h} and @samp{l}.
333
fcaaac0a 334@item @var{op} (iy+@var{d}), @var{r}
3c9b82ba
NC
335As above, but with @samp{iy} instead of @samp{ix}.
336@end table
337
338The web site at @uref{http://www.z80.info} is a good starting place to
339find more information on programming the Z80.
340
6655dba2
SB
341You may enable or disable any of these instructions for any target CPU
342even this instruction is not supported by any real CPU of this type.
343Useful for custom CPU cores.
This page took 0.584862 seconds and 4 git commands to generate.