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