Commit | Line | Data |
---|---|---|
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 | ||
14 | The Freescale S12Z version of @code{@value{AS}} has a few machine | |
15 | dependent 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 |
31 | The S12Z version of @code{@value{AS}} has the following options: |
32 | ||
33 | @cindex @samp{-mreg-prefix=@var{prefix}} option, reg-prefix | |
34 | You can use the @samp{-mreg-prefix=@var{pfx}} option to indicate | |
35 | that the assembler expects each register name to be prefixed with the | |
36 | string @var{pfx}. | |
37 | ||
38 | For an explanation of what this means and why it might be needed, | |
39 | see @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 | ||
53 | In the S12Z syntax, the instruction name comes first and it may | |
54 | be followed by one or by several operands. | |
55 | In most cases the maximum number of operands is three. | |
56 | Some instructions accept and (in certain situations require) a suffix | |
57 | indicating the size of the operand. | |
58 | The suffix is separated from the instruction name by a period (@samp{.}) | |
59 | and 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) | |
61 | respectively. | |
62 | Operands are separated by a comma (@samp{,}). | |
63 | A 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 | |
66 | are specified for a given instruction. | |
67 | The MRI mode is not supported for this architecture. | |
68 | Example: | |
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 | |
84 | The presence of a @samp{;} character anywhere | |
85 | on a line indicates the start of a comment that extends to the end of | |
86 | that line. | |
87 | ||
88 | A @samp{*} or a @samp{#} character at the start of a line also | |
89 | introduces a line comment, but these characters do not work elsewhere | |
90 | on the line. If the first character of the line is a @samp{#} then as | |
91 | well as starting a comment, the line could also be logical line number | |
92 | directive (@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 | |
98 | The S12Z assembler does not currently support a line separator | |
99 | character. | |
100 | ||
101 | @cindex S12Z addressing modes | |
102 | @cindex addressing modes, S12Z | |
103 | The 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 | ||
111 | Bit field instructions in the immediate mode require the width and offset to | |
112 | be specified. | |
113 | The @var{width} pararmeter specifies the number of bits in the field. | |
114 | It should be a number in the range [1,32]. | |
115 | @var{Offset} determines the position within the field where the operation | |
116 | should start. | |
117 | It should be a number in the range [0,31]. | |
118 | ||
119 | @item Relative | |
120 | @samp{*@var{symbol}}, or @samp{*[+-]@var{digits}} | |
121 | ||
122 | Program counter relative addresses have a width of 15 bits. | |
123 | Thus, they must be within the range [-32768, 32767]. | |
124 | ||
125 | @item Register | |
126 | @samp{@var{reg}} | |
127 | ||
95008a88 | 128 | @cindex register names, S12Z |
7b4ae824 | 129 | Some instructions accept a register as an operand. |
95008a88 JD |
130 | In general, @var{reg} may be a |
131 | data register (@samp{D0}, @samp{D1} @dots{} @samp{D7}), | |
132 | the @samp{X} register or the @samp{Y} register. | |
7b4ae824 JD |
133 | |
134 | A few instructions accept as an argument the stack pointer | |
135 | register (@samp{S}), and/or the program counter (@samp{P}). | |
136 | ||
137 | Some very special instructions accept arguments which refer to the | |
138 | condition code register. For these arguments the syntax is | |
95008a88 JD |
139 | @samp{CCR}, @samp{CCH} or @samp{CCL} which refer to the complete |
140 | condition code register, the condition code register high byte | |
141 | and 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}. | |
157 | If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then the | |
158 | register value is treated as a signed value. | |
159 | Otherwise 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 | ||
175 | This addressing mode is typically used to access a value at an address, | |
176 | and simultaneously to increment/decrement the register pointing to that | |
177 | address. | |
178 | Thus @var{reg} may be any of the 24 bit registers @samp{X}, @samp{Y}, or | |
179 | @samp{S}. | |
180 | Pre-increment and post-decrement are not available for | |
181 | register @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} | |
188 | must be one of the data registers @samp{D0}, @samp{D1} @dots{} @samp{D7}. | |
189 | If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then | |
190 | the register value is treated as a signed value. | |
191 | Otherwise 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} | |
198 | must be one of the data registers @samp{D0}, @samp{D1} @dots{} @samp{D7}. | |
199 | If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then | |
200 | the register value is treated as a signed value. | |
201 | Otherwise it is treated as unsigned. | |
7b4ae824 JD |
202 | @end table |
203 | ||
204 | For 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 | |
225 | Without a register prefix (@pxref{S12Z-Opts}), S12Z assembler code is expected in the traditional | |
226 | format like this: | |
227 | @smallexample | |
228 | lea s, (-2,s) | |
229 | st d2, (0,s) | |
230 | ld x, symbol | |
231 | tfr d2, d6 | |
232 | cmp d6, #1532 | |
233 | @end smallexample | |
234 | ||
235 | @noindent | |
236 | However, if @code{@value{AS}} is started with (for example) @samp{-mreg-prefix=%} | |
237 | then all register names must be prefixed with @samp{%} as follows: | |
238 | @smallexample | |
239 | lea %s, (-2,%s) | |
240 | st %d2, (0,%s) | |
241 | ld %x, symbol | |
242 | tfr %d2, %d6 | |
243 | cmp %d6, #1532 | |
244 | @end smallexample | |
245 | ||
246 | The register prefix feature is intended to be used by compilers | |
247 | to avoid ambiguity between symbols and register names. | |
248 | Consider the following assembler instruction: | |
249 | @smallexample | |
250 | st d0, d1 | |
251 | @end smallexample | |
252 | @noindent | |
253 | This instruction is most likely to | |
254 | mean ``Store the value in the register D0 into the register D1'' and that is the | |
255 | default way in which @code{@value{AS}} interprets it. | |
256 | However it could also be intended to mean | |
257 | ``Store the value in the register D0 into the memory referenced by the symbol | |
258 | named @samp{d1}''. | |
259 | If 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 | |
262 | st @var{pfx}d0, d1 | |
263 | @end smallexample | |
264 | @noindent | |
265 | where @var{pfx} is the chosen register prefix. | |
266 | For this reason, compiler back-ends should choose a register prefix which | |
267 | cannot 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 |