GAS (documentation): Remove trademark acknowledgements.
[deliverable/binutils-gdb.git] / gas / doc / c-s12z.texi
CommitLineData
82704155 1@c Copyright (C) 2018-2019 Free Software Foundation, Inc.
7b4ae824
JD
2@c This is part of the GAS manual.
3@c For copying conditions, see the file as.texinfo.
4@ifset GENERIC
5@page
6@node S12Z-Dependent
95008a88 7@chapter S12Z Dependent Features
7b4ae824
JD
8@end ifset
9@ifclear GENERIC
10@node Machine Dependencies
95008a88 11@chapter S12Z Dependent Features
7b4ae824
JD
12@end ifclear
13
14The Freescale S12Z version of @code{@value{AS}} has a few machine
15dependent features.
16
17@cindex S12Z support
18@menu
19* S12Z-Opts:: S12Z Options
20* S12Z-Syntax:: Syntax
21* S12Z-Directives:: Assembler Directives
95008a88 22* S12Z-Opcodes:: Opcodes
7b4ae824
JD
23@end menu
24
25@node S12Z-Opts
26@section S12Z Options
27
28@cindex options, S12Z
29@cindex S12Z options
30
95008a88
JD
31The S12Z version of @code{@value{AS}} has the following options:
32
33@cindex @samp{-mreg-prefix=@var{prefix}} option, reg-prefix
34You can use the @samp{-mreg-prefix=@var{pfx}} option to indicate
35that the assembler expects each register name to be prefixed with the
36string @var{pfx}.
37
38For an explanation of what this means and why it might be needed,
39see @ref{Register Notation}.
40
7b4ae824
JD
41@node S12Z-Syntax
42@section Syntax
43
95008a88
JD
44
45@menu
46* Register Notation:: How to refer to registers
47@end menu
48
49
7b4ae824
JD
50@cindex S12Z syntax
51@cindex syntax, S12Z
52
53In the S12Z syntax, the instruction name comes first and it may
54be followed by one or by several operands.
55In most cases the maximum number of operands is three.
56Some instructions accept and (in certain situations require) a suffix
57indicating the size of the operand.
58The suffix is separated from the instruction name by a period (@samp{.})
59and may be one of @samp{b}, @samp{w}, @samp{p} or @samp{l} indicating
60`byte' (a single byte), `word' (2 bytes), `pointer' (3 bytes) or `long' (4 bytes)
61respectively.
62Operands are separated by a comma (@samp{,}).
63A comma however does not act as a separator if it appears within parentheses
64(@samp{()}) or within square brackets (@samp{[]}).
65@code{@value{AS}} will complain if too many, too few or inappropriate operands
66are specified for a given instruction.
67The MRI mode is not supported for this architecture.
68Example:
69
70@smallexample
71 bset.b 0xA98, #5
72 mov.b #6, 0x2409
73 ld d0, #4
74 mov.l (d0, x), 0x2409
75 inc d0
76 cmp d0, #12
77 blt *-4
78 lea x, 0x2409
79 st y, (1, x)
80@end smallexample
81
82@cindex line comment character, S12Z
83@cindex S12Z line comment character
84The presence of a @samp{;} character anywhere
85on a line indicates the start of a comment that extends to the end of
86that line.
87
88A @samp{*} or a @samp{#} character at the start of a line also
89introduces a line comment, but these characters do not work elsewhere
90on the line. If the first character of the line is a @samp{#} then as
91well as starting a comment, the line could also be logical line number
92directive (@pxref{Comments}) or a preprocessor control command
93(@pxref{Preprocessing}).
94
95@cindex line separator, S12Z
96@cindex statement separator, S12Z
97@cindex S12Z line separator
98The S12Z assembler does not currently support a line separator
99character.
100
101@cindex S12Z addressing modes
102@cindex addressing modes, S12Z
103The following addressing modes are understood for the S12Z.
104@table @dfn
105@item Immediate
106@samp{#@var{number}}
107
108@item Immediate Bit Field
109@samp{#@var{width}:@var{offset}}
110
111Bit field instructions in the immediate mode require the width and offset to
112be specified.
113The @var{width} pararmeter specifies the number of bits in the field.
114It should be a number in the range [1,32].
115@var{Offset} determines the position within the field where the operation
116should start.
117It should be a number in the range [0,31].
118
119@item Relative
120@samp{*@var{symbol}}, or @samp{*[+-]@var{digits}}
121
122Program counter relative addresses have a width of 15 bits.
123Thus, they must be within the range [-32768, 32767].
124
125@item Register
126@samp{@var{reg}}
127
95008a88 128@cindex register names, S12Z
7b4ae824 129Some instructions accept a register as an operand.
95008a88
JD
130In general, @var{reg} may be a
131data register (@samp{D0}, @samp{D1} @dots{} @samp{D7}),
132the @samp{X} register or the @samp{Y} register.
7b4ae824
JD
133
134A few instructions accept as an argument the stack pointer
135register (@samp{S}), and/or the program counter (@samp{P}).
136
137Some very special instructions accept arguments which refer to the
138condition code register. For these arguments the syntax is
95008a88
JD
139@samp{CCR}, @samp{CCH} or @samp{CCL} which refer to the complete
140condition code register, the condition code register high byte
141and the condition code register low byte respectively.
142
7b4ae824
JD
143
144@item Absolute Direct
145@samp{@var{symbol}}, or @samp{@var{digits}}
146
147@item Absolute Indirect
148@samp{[@var{symbol}}, or @samp{@var{digits}]}
149
150
151@item Constant Offset Indexed
152@samp{(@var{number},@var{reg})}
153
154@var{Reg} may be either @samp{X}, @samp{Y}, @samp{S} or
155@samp{P} or one of the data registers @samp{D0}, @samp{D1} @dots{}
156@samp{D7}.
157If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then the
158register value is treated as a signed value.
159Otherwise it is treated as unsigned.
160@var{Number} may be any integer in the range [-8388608,8388607].
161
162@item Offset Indexed Indirect
163@samp{[@var{number},@var{reg}]}
164
165@var{Reg} may be either @samp{X}, @samp{Y}, @samp{S} or
166@samp{P}.
167@var{Number} may be any integer in the range [-8388608,8388607].
168
169@item Auto Pre-Increment/Pre-Decrement/Post-Increment/Post-Decrement
170@samp{-@var{reg}},
171@samp{+@var{reg}},
172@samp{@var{reg}-} or
173@samp{@var{reg}+}
174
175This addressing mode is typically used to access a value at an address,
176and simultaneously to increment/decrement the register pointing to that
177address.
178Thus @var{reg} may be any of the 24 bit registers @samp{X}, @samp{Y}, or
179@samp{S}.
180Pre-increment and post-decrement are not available for
181register @samp{S} (only post-increment and pre-decrement are available).
182
183@item Register Offset Direct
184@samp{(@var{data-reg},@var{reg})}
185
186@var{Reg} can be either @samp{X}, @samp{Y}, or @samp{S}.
187@var{Data-reg}
188must be one of the data registers @samp{D0}, @samp{D1} @dots{} @samp{D7}.
189If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then
190the register value is treated as a signed value.
191Otherwise it is treated as unsigned.
192
193@item Register Offset Indirect
194@samp{[@var{data-reg},@var{reg}]}
195
196@var{Reg} can be either @samp{X} or @samp{Y}.
197@var{Data-reg}
198must be one of the data registers @samp{D0}, @samp{D1} @dots{} @samp{D7}.
199If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then
200the register value is treated as a signed value.
201Otherwise it is treated as unsigned.
7b4ae824
JD
202@end table
203
204For example:
205
206@smallexample
207 trap #197
208 bra *+49
209 bra .L0
210 jmp 0xFE0034
211 jmp [0xFD0012]
212 inc.b (4,x)
213 dec.w [4,y]
214 clr.p (-s)
215 neg.l (d0, s)
216 com.b [d1, x]
217 jsr (45, d0)
218 psh cch
219@end smallexample
220
95008a88
JD
221@node Register Notation
222@subsection Register Notation
223
224@cindex register notation, S12Z
225Without a register prefix (@pxref{S12Z-Opts}), S12Z assembler code is expected in the traditional
226format like this:
227@smallexample
228lea s, (-2,s)
229st d2, (0,s)
230ld x, symbol
231tfr d2, d6
232cmp d6, #1532
233@end smallexample
234
235@noindent
236However, if @code{@value{AS}} is started with (for example) @samp{-mreg-prefix=%}
237then all register names must be prefixed with @samp{%} as follows:
238@smallexample
239lea %s, (-2,%s)
240st %d2, (0,%s)
241ld %x, symbol
242tfr %d2, %d6
243cmp %d6, #1532
244@end smallexample
245
246The register prefix feature is intended to be used by compilers
247to avoid ambiguity between symbols and register names.
248Consider the following assembler instruction:
249@smallexample
250st d0, d1
251@end smallexample
252@noindent
253This instruction is most likely to
254mean ``Store the value in the register D0 into the register D1'' and that is the
255default way in which @code{@value{AS}} interprets it.
256However it could also be intended to mean
257``Store the value in the register D0 into the memory referenced by the symbol
258named @samp{d1}''.
259If that is what is intended then @code{@value{AS}} must be invoked with
260@samp{-mreg-prefix=@var{pfx}} and the code written as
261@smallexample
262st @var{pfx}d0, d1
263@end smallexample
264@noindent
265where @var{pfx} is the chosen register prefix.
266For this reason, compiler back-ends should choose a register prefix which
267cannot be confused with a symbol name.
268
269
7b4ae824
JD
270@node S12Z-Directives
271@section Assembler Directives
272
273@cindex assembler directives, S12Z
274
95008a88 275@node S12Z-Opcodes
7b4ae824
JD
276@section Opcodes
277
278@cindex S12Z opcodes
279@cindex opcodes, S12Z
280@cindex instruction set, S12Z
This page took 0.072018 seconds and 4 git commands to generate.