1 @c Copyright (C) 2018-2022 Free Software Foundation, Inc.
2 @c This is part of the GAS manual.
3 @c For copying conditions, see the file as.texinfo.
7 @chapter S12Z Dependent Features
10 @node Machine Dependencies
11 @chapter S12Z Dependent Features
14 The Freescale S12Z version of @code{@value{AS}} has a few machine
19 * S12Z Options:: S12Z Options
20 * S12Z Syntax:: Syntax
29 The S12Z version of @code{@value{AS}} recognizes the following options:
33 @item -mreg-prefix=@var{prefix}
34 @cindex @samp{-mreg-prefix=@var{prefix}} option, reg-prefix
35 You can use the @samp{-mreg-prefix=@var{pfx}} option to indicate
36 that the assembler should expect all register names to be prefixed with the
39 For an explanation of what this means and why it might be needed,
40 see @ref{S12Z Register Notation}.
44 @cindex @samp{-mdollar-hex} option, dollar-hex
45 @cindex hexadecimal prefix, S12Z
46 The @samp{-mdollar-hex} option affects the way that literal hexadecimal constants
47 are represented. When this option is specified, the assembler will consider
48 the @samp{$} character as the start of a hexadecimal integer constant. Without
49 this option, the standard value of @samp{0x} is expected.
51 If 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.
61 * S12Z Syntax Overview:: General description
62 * S12Z Addressing Modes:: Operands and their semantics
63 * S12Z Register Notation:: How to refer to registers
70 @node S12Z Syntax Overview
73 In the S12Z syntax, the instruction name comes first and it may
74 be followed by one, or by several operands.
75 In most cases the maximum number of operands is three.
76 Operands are separated by a comma (@samp{,}).
77 A 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
80 are specified for a given instruction.
82 Some instructions accept and (in certain situations require) a suffix
83 indicating the size of the operand.
84 The suffix is separated from the instruction name by a period (@samp{.})
85 and 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)
103 @cindex line comment character, S12Z
104 The presence of a @samp{;} character anywhere
105 on a line indicates the start of a comment that extends to the end of
108 A @samp{*} or a @samp{#} character at the start of a line also
109 introduces a line comment, but these characters do not work elsewhere
110 on the line. If the first character of the line is a @samp{#} then as
111 well as starting a comment, the line could also be logical line number
112 directive (@pxref{Comments}) or a preprocessor control command
113 (@pxref{Preprocessing}).
115 @cindex line separator, S12Z
116 @cindex statement separator, S12Z
117 @cindex S12Z line separator
118 The S12Z assembler does not currently support a line separator
122 @node S12Z Addressing Modes
123 @subsection Addressing Modes
124 @cindex S12Z addressing modes
125 @cindex addressing modes, S12Z
127 The following addressing modes are understood for the S12Z.
132 @item Immediate Bit Field
133 @samp{#@var{width}:@var{offset}}
135 Bit field instructions in the immediate mode require the width and offset to
137 The @var{width} parameter specifies the number of bits in the field.
138 It should be a number in the range [1,32].
139 @var{Offset} determines the position within the field where the operation
141 It should be a number in the range [0,31].
144 @samp{*@var{symbol}}, or @samp{*[+-]@var{digits}}
146 Program counter relative addresses have a width of 15 bits.
147 Thus, they must be within the range [-32768, 32767].
152 @cindex register names, S12Z
153 Some instructions accept a register as an operand.
154 In general, @var{reg} may be a
155 data register (@samp{D0}, @samp{D1} @dots{} @samp{D7}),
156 the @samp{X} register or the @samp{Y} register.
158 A few instructions accept as an argument the stack pointer
159 register (@samp{S}), and/or the program counter (@samp{P}).
161 Some very special instructions accept arguments which refer to the
162 condition code register. For these arguments the syntax is
163 @samp{CCR}, @samp{CCH} or @samp{CCL} which refer to the complete
164 condition code register, the condition code register high byte
165 and the condition code register low byte respectively.
168 @item Absolute Direct
169 @samp{@var{symbol}}, or @samp{@var{digits}}
171 @item Absolute Indirect
172 @samp{[@var{symbol}}, or @samp{@var{digits}]}
175 @item Constant Offset Indexed
176 @samp{(@var{number},@var{reg})}
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{}
181 If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then the
182 register value is treated as a signed value.
183 Otherwise it is treated as unsigned.
184 @var{Number} may be any integer in the range [-8388608,8388607].
186 @item Offset Indexed Indirect
187 @samp{[@var{number},@var{reg}]}
189 @var{Reg} may be either @samp{X}, @samp{Y}, @samp{S} or
191 @var{Number} may be any integer in the range [-8388608,8388607].
193 @item Auto Pre-Increment/Pre-Decrement/Post-Increment/Post-Decrement
199 This addressing mode is typically used to access a value at an address,
200 and simultaneously to increment/decrement the register pointing to that
202 Thus @var{reg} may be any of the 24 bit registers @samp{X}, @samp{Y}, or
204 Pre-increment and post-decrement are not available for
205 register @samp{S} (only post-increment and pre-decrement are available).
207 @item Register Offset Direct
208 @samp{(@var{data-reg},@var{reg})}
210 @var{Reg} can be either @samp{X}, @samp{Y}, or @samp{S}.
212 must be one of the data registers @samp{D0}, @samp{D1} @dots{} @samp{D7}.
213 If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then
214 the register value is treated as a signed value.
215 Otherwise it is treated as unsigned.
217 @item Register Offset Indirect
218 @samp{[@var{data-reg},@var{reg}]}
220 @var{Reg} can be either @samp{X} or @samp{Y}.
222 must be one of the data registers @samp{D0}, @samp{D1} @dots{} @samp{D7}.
223 If any of the registers @samp{D2} @dots{} @samp{D5} are specified, then
224 the register value is treated as a signed value.
225 Otherwise it is treated as unsigned.
231 trap #197 ;; Immediate mode
232 bra *+49 ;; Relative mode
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
245 @node S12Z Register Notation
246 @subsection Register Notation
248 @cindex register notation, S12Z
249 Without a register prefix (@pxref{S12Z Options}), S12Z assembler code is expected in the traditional
260 However, if @code{@value{AS}} is started with (for example) @samp{-mreg-prefix=%}
261 then all register names must be prefixed with @samp{%} as follows:
270 The register prefix feature is intended to be used by compilers
271 to avoid ambiguity between symbols and register names.
272 Consider the following assembler instruction:
277 The destination operand of this instruction could either refer to the register
278 @samp{D1}, or it could refer to the symbol named ``d1''.
279 If the latter is intended then @code{@value{AS}} must be invoked with
280 @samp{-mreg-prefix=@var{pfx}} and the code written as
285 where @var{pfx} is the chosen register prefix.
286 For this reason, compiler back-ends should choose a register prefix which
287 cannot be confused with a symbol name.