1 |
38 |
julius |
@c Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
|
2 |
|
|
@c This is part of the GAS manual.
|
3 |
|
|
@c For copying conditions, see the file as.texinfo.
|
4 |
|
|
@c MMIX description by Hans-Peter Nilsson, hp@bitrange.com
|
5 |
|
|
@ifset GENERIC
|
6 |
|
|
@page
|
7 |
|
|
@node MMIX-Dependent
|
8 |
|
|
@chapter MMIX Dependent Features
|
9 |
|
|
@end ifset
|
10 |
|
|
@ifclear GENERIC
|
11 |
|
|
@node Machine Dependencies
|
12 |
|
|
@chapter MMIX Dependent Features
|
13 |
|
|
@end ifclear
|
14 |
|
|
|
15 |
|
|
@cindex MMIX support
|
16 |
|
|
@menu
|
17 |
|
|
* MMIX-Opts:: Command-line Options
|
18 |
|
|
* MMIX-Expand:: Instruction expansion
|
19 |
|
|
* MMIX-Syntax:: Syntax
|
20 |
|
|
* MMIX-mmixal:: Differences to @code{mmixal} syntax and semantics
|
21 |
|
|
@end menu
|
22 |
|
|
|
23 |
|
|
@node MMIX-Opts
|
24 |
|
|
@section Command-line Options
|
25 |
|
|
|
26 |
|
|
@cindex options, MMIX
|
27 |
|
|
@cindex MMIX options
|
28 |
|
|
The MMIX version of @code{@value{AS}} has some machine-dependent options.
|
29 |
|
|
|
30 |
|
|
@cindex @samp{--fixed-special-register-names} command line option, MMIX
|
31 |
|
|
When @samp{--fixed-special-register-names} is specified, only the register
|
32 |
|
|
names specified in @ref{MMIX-Regs} are recognized in the instructions
|
33 |
|
|
@code{PUT} and @code{GET}.
|
34 |
|
|
|
35 |
|
|
@cindex @samp{--globalize-symbols} command line option, MMIX
|
36 |
|
|
You can use the @samp{--globalize-symbols} to make all symbols global.
|
37 |
|
|
This option is useful when splitting up a @code{mmixal} program into
|
38 |
|
|
several files.
|
39 |
|
|
|
40 |
|
|
@cindex @samp{--gnu-syntax} command line option, MMIX
|
41 |
|
|
The @samp{--gnu-syntax} turns off most syntax compatibility with
|
42 |
|
|
@code{mmixal}. Its usability is currently doubtful.
|
43 |
|
|
|
44 |
|
|
@cindex @samp{--relax} command line option, MMIX
|
45 |
|
|
The @samp{--relax} option is not fully supported, but will eventually make
|
46 |
|
|
the object file prepared for linker relaxation.
|
47 |
|
|
|
48 |
|
|
@cindex @samp{--no-predefined-syms} command line option, MMIX
|
49 |
|
|
If you want to avoid inadvertently calling a predefined symbol and would
|
50 |
|
|
rather get an error, for example when using @code{@value{AS}} with a
|
51 |
|
|
compiler or other machine-generated code, specify
|
52 |
|
|
@samp{--no-predefined-syms}. This turns off built-in predefined
|
53 |
|
|
definitions of all such symbols, including rounding-mode symbols, segment
|
54 |
|
|
symbols, @samp{BIT} symbols, and @code{TRAP} symbols used in @code{mmix}
|
55 |
|
|
``system calls''. It also turns off predefined special-register names,
|
56 |
|
|
except when used in @code{PUT} and @code{GET} instructions.
|
57 |
|
|
|
58 |
|
|
@cindex @samp{--no-expand} command line option, MMIX
|
59 |
|
|
By default, some instructions are expanded to fit the size of the operand
|
60 |
|
|
or an external symbol (@pxref{MMIX-Expand}). By passing
|
61 |
|
|
@samp{--no-expand}, no such expansion will be done, instead causing errors
|
62 |
|
|
at link time if the operand does not fit.
|
63 |
|
|
|
64 |
|
|
@cindex @samp{--no-merge-gregs} command line option, MMIX
|
65 |
|
|
The @code{mmixal} documentation (@pxref{mmixsite}) specifies that global
|
66 |
|
|
registers allocated with the @samp{GREG} directive (@pxref{MMIX-greg}) and
|
67 |
|
|
initialized to the same non-zero value, will refer to the same global
|
68 |
|
|
register. This isn't strictly enforceable in @code{@value{AS}} since the
|
69 |
|
|
final addresses aren't known until link-time, but it will do an effort
|
70 |
|
|
unless the @samp{--no-merge-gregs} option is specified. (Register merging
|
71 |
|
|
isn't yet implemented in @code{@value{LD}}.)
|
72 |
|
|
|
73 |
|
|
@cindex @samp{-x} command line option, MMIX
|
74 |
|
|
@code{@value{AS}} will warn every time it expands an instruction to fit an
|
75 |
|
|
operand unless the option @samp{-x} is specified. It is believed that
|
76 |
|
|
this behaviour is more useful than just mimicking @code{mmixal}'s
|
77 |
|
|
behaviour, in which instructions are only expanded if the @samp{-x} option
|
78 |
|
|
is specified, and assembly fails otherwise, when an instruction needs to
|
79 |
|
|
be expanded. It needs to be kept in mind that @code{mmixal} is both an
|
80 |
|
|
assembler and linker, while @code{@value{AS}} will expand instructions
|
81 |
|
|
that at link stage can be contracted. (Though linker relaxation isn't yet
|
82 |
|
|
implemented in @code{@value{LD}}.) The option @samp{-x} also imples
|
83 |
|
|
@samp{--linker-allocated-gregs}.
|
84 |
|
|
|
85 |
|
|
@cindex @samp{--no-pushj-stubs} command line option, MMIX
|
86 |
|
|
@cindex @samp{--no-stubs} command line option, MMIX
|
87 |
|
|
If instruction expansion is enabled, @code{@value{AS}} can expand a
|
88 |
|
|
@samp{PUSHJ} instruction into a series of instructions. The shortest
|
89 |
|
|
expansion is to not expand it, but just mark the call as redirectable to a
|
90 |
|
|
stub, which @code{@value{LD}} creates at link-time, but only if the
|
91 |
|
|
original @samp{PUSHJ} instruction is found not to reach the target. The
|
92 |
|
|
stub consists of the necessary instructions to form a jump to the target.
|
93 |
|
|
This happens if @code{@value{AS}} can assert that the @samp{PUSHJ}
|
94 |
|
|
instruction can reach such a stub. The option @samp{--no-pushj-stubs}
|
95 |
|
|
disables this shorter expansion, and the longer series of instructions is
|
96 |
|
|
then created at assembly-time. The option @samp{--no-stubs} is a synonym,
|
97 |
|
|
intended for compatibility with future releases, where generation of stubs
|
98 |
|
|
for other instructions may be implemented.
|
99 |
|
|
|
100 |
|
|
@cindex @samp{--linker-allocated-gregs} command line option, MMIX
|
101 |
|
|
Usually a two-operand-expression (@pxref{GREG-base}) without a matching
|
102 |
|
|
@samp{GREG} directive is treated as an error by @code{@value{AS}}. When
|
103 |
|
|
the option @samp{--linker-allocated-gregs} is in effect, they are instead
|
104 |
|
|
passed through to the linker, which will allocate as many global registers
|
105 |
|
|
as is needed.
|
106 |
|
|
|
107 |
|
|
@node MMIX-Expand
|
108 |
|
|
@section Instruction expansion
|
109 |
|
|
|
110 |
|
|
@cindex instruction expansion, MMIX
|
111 |
|
|
When @code{@value{AS}} encounters an instruction with an operand that is
|
112 |
|
|
either not known or does not fit the operand size of the instruction,
|
113 |
|
|
@code{@value{AS}} (and @code{@value{LD}}) will expand the instruction into
|
114 |
|
|
a sequence of instructions semantically equivalent to the operand fitting
|
115 |
|
|
the instruction. Expansion will take place for the following
|
116 |
|
|
instructions:
|
117 |
|
|
|
118 |
|
|
@table @asis
|
119 |
|
|
@item @samp{GETA}
|
120 |
|
|
Expands to a sequence of four instructions: @code{SETL}, @code{INCML},
|
121 |
|
|
@code{INCMH} and @code{INCH}. The operand must be a multiple of four.
|
122 |
|
|
@item Conditional branches
|
123 |
|
|
A branch instruction is turned into a branch with the complemented
|
124 |
|
|
condition and prediction bit over five instructions; four instructions
|
125 |
|
|
setting @code{$255} to the operand value, which like with @code{GETA} must
|
126 |
|
|
be a multiple of four, and a final @code{GO $255,$255,0}.
|
127 |
|
|
@item @samp{PUSHJ}
|
128 |
|
|
Similar to expansion for conditional branches; four instructions set
|
129 |
|
|
@code{$255} to the operand value, followed by a @code{PUSHGO $255,$255,0}.
|
130 |
|
|
@item @samp{JMP}
|
131 |
|
|
Similar to conditional branches and @code{PUSHJ}. The final instruction
|
132 |
|
|
is @code{GO $255,$255,0}.
|
133 |
|
|
@end table
|
134 |
|
|
|
135 |
|
|
The linker @code{@value{LD}} is expected to shrink these expansions for
|
136 |
|
|
code assembled with @samp{--relax} (though not currently implemented).
|
137 |
|
|
|
138 |
|
|
@node MMIX-Syntax
|
139 |
|
|
@section Syntax
|
140 |
|
|
|
141 |
|
|
The assembly syntax is supposed to be upward compatible with that
|
142 |
|
|
described in Sections 1.3 and 1.4 of @samp{The Art of Computer
|
143 |
|
|
Programming, Volume 1}. Draft versions of those chapters as well as other
|
144 |
|
|
MMIX information is located at
|
145 |
|
|
@anchor{mmixsite}@url{http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html}.
|
146 |
|
|
Most code examples from the mmixal package located there should work
|
147 |
|
|
unmodified when assembled and linked as single files, with a few
|
148 |
|
|
noteworthy exceptions (@pxref{MMIX-mmixal}).
|
149 |
|
|
|
150 |
|
|
Before an instruction is emitted, the current location is aligned to the
|
151 |
|
|
next four-byte boundary. If a label is defined at the beginning of the
|
152 |
|
|
line, its value will be the aligned value.
|
153 |
|
|
|
154 |
|
|
In addition to the traditional hex-prefix @samp{0x}, a hexadecimal number
|
155 |
|
|
can also be specified by the prefix character @samp{#}.
|
156 |
|
|
|
157 |
|
|
After all operands to an MMIX instruction or directive have been
|
158 |
|
|
specified, the rest of the line is ignored, treated as a comment.
|
159 |
|
|
|
160 |
|
|
@menu
|
161 |
|
|
* MMIX-Chars:: Special Characters
|
162 |
|
|
* MMIX-Symbols:: Symbols
|
163 |
|
|
* MMIX-Regs:: Register Names
|
164 |
|
|
* MMIX-Pseudos:: Assembler Directives
|
165 |
|
|
@end menu
|
166 |
|
|
|
167 |
|
|
@node MMIX-Chars
|
168 |
|
|
@subsection Special Characters
|
169 |
|
|
@cindex line comment characters, MMIX
|
170 |
|
|
@cindex MMIX line comment characters
|
171 |
|
|
|
172 |
|
|
The characters @samp{*} and @samp{#} are line comment characters; each
|
173 |
|
|
start a comment at the beginning of a line, but only at the beginning of a
|
174 |
|
|
line. A @samp{#} prefixes a hexadecimal number if found elsewhere on a
|
175 |
|
|
line.
|
176 |
|
|
|
177 |
|
|
Two other characters, @samp{%} and @samp{!}, each start a comment anywhere
|
178 |
|
|
on the line. Thus you can't use the @samp{modulus} and @samp{not}
|
179 |
|
|
operators in expressions normally associated with these two characters.
|
180 |
|
|
|
181 |
|
|
A @samp{;} is a line separator, treated as a new-line, so separate
|
182 |
|
|
instructions can be specified on a single line.
|
183 |
|
|
|
184 |
|
|
@node MMIX-Symbols
|
185 |
|
|
@subsection Symbols
|
186 |
|
|
The character @samp{:} is permitted in identifiers. There are two
|
187 |
|
|
exceptions to it being treated as any other symbol character: if a symbol
|
188 |
|
|
begins with @samp{:}, it means that the symbol is in the global namespace
|
189 |
|
|
and that the current prefix should not be prepended to that symbol
|
190 |
|
|
(@pxref{MMIX-prefix}). The @samp{:} is then not considered part of the
|
191 |
|
|
symbol. For a symbol in the label position (first on a line), a @samp{:}
|
192 |
|
|
at the end of a symbol is silently stripped off. A label is permitted,
|
193 |
|
|
but not required, to be followed by a @samp{:}, as with many other
|
194 |
|
|
assembly formats.
|
195 |
|
|
|
196 |
|
|
The character @samp{@@} in an expression, is a synonym for @samp{.}, the
|
197 |
|
|
current location.
|
198 |
|
|
|
199 |
|
|
In addition to the common forward and backward local symbol formats
|
200 |
|
|
(@pxref{Symbol Names}), they can be specified with upper-case @samp{B} and
|
201 |
|
|
@samp{F}, as in @samp{8B} and @samp{9F}. A local label defined for the
|
202 |
|
|
current position is written with a @samp{H} appended to the number:
|
203 |
|
|
@smallexample
|
204 |
|
|
3H LDB $0,$1,2
|
205 |
|
|
@end smallexample
|
206 |
|
|
This and traditional local-label formats cannot be mixed: a label must be
|
207 |
|
|
defined and referred to using the same format.
|
208 |
|
|
|
209 |
|
|
There's a minor caveat: just as for the ordinary local symbols, the local
|
210 |
|
|
symbols are translated into ordinary symbols using control characters are
|
211 |
|
|
to hide the ordinal number of the symbol. Unfortunately, these symbols
|
212 |
|
|
are not translated back in error messages. Thus you may see confusing
|
213 |
|
|
error messages when local symbols are used. Control characters
|
214 |
|
|
@samp{\003} (control-C) and @samp{\004} (control-D) are used for the
|
215 |
|
|
MMIX-specific local-symbol syntax.
|
216 |
|
|
|
217 |
|
|
The symbol @samp{Main} is handled specially; it is always global.
|
218 |
|
|
|
219 |
|
|
By defining the symbols @samp{__.MMIX.start..text} and
|
220 |
|
|
@samp{__.MMIX.start..data}, the address of respectively the @samp{.text}
|
221 |
|
|
and @samp{.data} segments of the final program can be defined, though when
|
222 |
|
|
linking more than one object file, the code or data in the object file
|
223 |
|
|
containing the symbol is not guaranteed to be start at that position; just
|
224 |
|
|
the final executable. @xref{MMIX-loc}.
|
225 |
|
|
|
226 |
|
|
@node MMIX-Regs
|
227 |
|
|
@subsection Register names
|
228 |
|
|
@cindex register names, MMIX
|
229 |
|
|
@cindex MMIX register names
|
230 |
|
|
|
231 |
|
|
Local and global registers are specified as @samp{$0} to @samp{$255}.
|
232 |
|
|
The recognized special register names are @samp{rJ}, @samp{rA}, @samp{rB},
|
233 |
|
|
@samp{rC}, @samp{rD}, @samp{rE}, @samp{rF}, @samp{rG}, @samp{rH},
|
234 |
|
|
@samp{rI}, @samp{rK}, @samp{rL}, @samp{rM}, @samp{rN}, @samp{rO},
|
235 |
|
|
@samp{rP}, @samp{rQ}, @samp{rR}, @samp{rS}, @samp{rT}, @samp{rU},
|
236 |
|
|
@samp{rV}, @samp{rW}, @samp{rX}, @samp{rY}, @samp{rZ}, @samp{rBB},
|
237 |
|
|
@samp{rTT}, @samp{rWW}, @samp{rXX}, @samp{rYY} and @samp{rZZ}. A leading
|
238 |
|
|
@samp{:} is optional for special register names.
|
239 |
|
|
|
240 |
|
|
Local and global symbols can be equated to register names and used in
|
241 |
|
|
place of ordinary registers.
|
242 |
|
|
|
243 |
|
|
Similarly for special registers, local and global symbols can be used.
|
244 |
|
|
Also, symbols equated from numbers and constant expressions are allowed in
|
245 |
|
|
place of a special register, except when either of the options
|
246 |
|
|
@code{--no-predefined-syms} and @code{--fixed-special-register-names} are
|
247 |
|
|
specified. Then only the special register names above are allowed for the
|
248 |
|
|
instructions having a special register operand; @code{GET} and @code{PUT}.
|
249 |
|
|
|
250 |
|
|
@node MMIX-Pseudos
|
251 |
|
|
@subsection Assembler Directives
|
252 |
|
|
@cindex assembler directives, MMIX
|
253 |
|
|
@cindex pseudo-ops, MMIX
|
254 |
|
|
@cindex MMIX assembler directives
|
255 |
|
|
@cindex MMIX pseudo-ops
|
256 |
|
|
|
257 |
|
|
@table @code
|
258 |
|
|
@item LOC
|
259 |
|
|
@cindex assembler directive LOC, MMIX
|
260 |
|
|
@cindex pseudo-op LOC, MMIX
|
261 |
|
|
@cindex MMIX assembler directive LOC
|
262 |
|
|
@cindex MMIX pseudo-op LOC
|
263 |
|
|
|
264 |
|
|
@anchor{MMIX-loc}
|
265 |
|
|
The @code{LOC} directive sets the current location to the value of the
|
266 |
|
|
operand field, which may include changing sections. If the operand is a
|
267 |
|
|
constant, the section is set to either @code{.data} if the value is
|
268 |
|
|
@code{0x2000000000000000} or larger, else it is set to @code{.text}.
|
269 |
|
|
Within a section, the current location may only be changed to
|
270 |
|
|
monotonically higher addresses. A LOC expression must be a previously
|
271 |
|
|
defined symbol or a ``pure'' constant.
|
272 |
|
|
|
273 |
|
|
An example, which sets the label @var{prev} to the current location, and
|
274 |
|
|
updates the current location to eight bytes forward:
|
275 |
|
|
@smallexample
|
276 |
|
|
prev LOC @@+8
|
277 |
|
|
@end smallexample
|
278 |
|
|
|
279 |
|
|
When a LOC has a constant as its operand, a symbol
|
280 |
|
|
@code{__.MMIX.start..text} or @code{__.MMIX.start..data} is defined
|
281 |
|
|
depending on the address as mentioned above. Each such symbol is
|
282 |
|
|
interpreted as special by the linker, locating the section at that
|
283 |
|
|
address. Note that if multiple files are linked, the first object file
|
284 |
|
|
with that section will be mapped to that address (not necessarily the file
|
285 |
|
|
with the LOC definition).
|
286 |
|
|
|
287 |
|
|
@item LOCAL
|
288 |
|
|
@cindex assembler directive LOCAL, MMIX
|
289 |
|
|
@cindex pseudo-op LOCAL, MMIX
|
290 |
|
|
@cindex MMIX assembler directive LOCAL
|
291 |
|
|
@cindex MMIX pseudo-op LOCAL
|
292 |
|
|
|
293 |
|
|
@anchor{MMIX-local}
|
294 |
|
|
Example:
|
295 |
|
|
@smallexample
|
296 |
|
|
LOCAL external_symbol
|
297 |
|
|
LOCAL 42
|
298 |
|
|
.local asymbol
|
299 |
|
|
@end smallexample
|
300 |
|
|
|
301 |
|
|
This directive-operation generates a link-time assertion that the operand
|
302 |
|
|
does not correspond to a global register. The operand is an expression
|
303 |
|
|
that at link-time resolves to a register symbol or a number. A number is
|
304 |
|
|
treated as the register having that number. There is one restriction on
|
305 |
|
|
the use of this directive: the pseudo-directive must be placed in a
|
306 |
|
|
section with contents, code or data.
|
307 |
|
|
|
308 |
|
|
@item IS
|
309 |
|
|
@cindex assembler directive IS, MMIX
|
310 |
|
|
@cindex pseudo-op IS, MMIX
|
311 |
|
|
@cindex MMIX assembler directive IS
|
312 |
|
|
@cindex MMIX pseudo-op IS
|
313 |
|
|
|
314 |
|
|
@anchor{MMIX-is}
|
315 |
|
|
The @code{IS} directive:
|
316 |
|
|
@smallexample
|
317 |
|
|
asymbol IS an_expression
|
318 |
|
|
@end smallexample
|
319 |
|
|
sets the symbol @samp{asymbol} to @samp{an_expression}. A symbol may not
|
320 |
|
|
be set more than once using this directive. Local labels may be set using
|
321 |
|
|
this directive, for example:
|
322 |
|
|
@smallexample
|
323 |
|
|
5H IS @@+4
|
324 |
|
|
@end smallexample
|
325 |
|
|
|
326 |
|
|
@item GREG
|
327 |
|
|
@cindex assembler directive GREG, MMIX
|
328 |
|
|
@cindex pseudo-op GREG, MMIX
|
329 |
|
|
@cindex MMIX assembler directive GREG
|
330 |
|
|
@cindex MMIX pseudo-op GREG
|
331 |
|
|
|
332 |
|
|
@anchor{MMIX-greg}
|
333 |
|
|
This directive reserves a global register, gives it an initial value and
|
334 |
|
|
optionally gives it a symbolic name. Some examples:
|
335 |
|
|
|
336 |
|
|
@smallexample
|
337 |
|
|
areg GREG
|
338 |
|
|
breg GREG data_value
|
339 |
|
|
GREG data_buffer
|
340 |
|
|
.greg creg, another_data_value
|
341 |
|
|
@end smallexample
|
342 |
|
|
|
343 |
|
|
The symbolic register name can be used in place of a (non-special)
|
344 |
|
|
register. If a value isn't provided, it defaults to zero. Unless the
|
345 |
|
|
option @samp{--no-merge-gregs} is specified, non-zero registers allocated
|
346 |
|
|
with this directive may be eliminated by @code{@value{AS}}; another
|
347 |
|
|
register with the same value used in its place.
|
348 |
|
|
Any of the instructions
|
349 |
|
|
@samp{CSWAP},
|
350 |
|
|
@samp{GO},
|
351 |
|
|
@samp{LDA},
|
352 |
|
|
@samp{LDBU},
|
353 |
|
|
@samp{LDB},
|
354 |
|
|
@samp{LDHT},
|
355 |
|
|
@samp{LDOU},
|
356 |
|
|
@samp{LDO},
|
357 |
|
|
@samp{LDSF},
|
358 |
|
|
@samp{LDTU},
|
359 |
|
|
@samp{LDT},
|
360 |
|
|
@samp{LDUNC},
|
361 |
|
|
@samp{LDVTS},
|
362 |
|
|
@samp{LDWU},
|
363 |
|
|
@samp{LDW},
|
364 |
|
|
@samp{PREGO},
|
365 |
|
|
@samp{PRELD},
|
366 |
|
|
@samp{PREST},
|
367 |
|
|
@samp{PUSHGO},
|
368 |
|
|
@samp{STBU},
|
369 |
|
|
@samp{STB},
|
370 |
|
|
@samp{STCO},
|
371 |
|
|
@samp{STHT},
|
372 |
|
|
@samp{STOU},
|
373 |
|
|
@samp{STSF},
|
374 |
|
|
@samp{STTU},
|
375 |
|
|
@samp{STT},
|
376 |
|
|
@samp{STUNC},
|
377 |
|
|
@samp{SYNCD},
|
378 |
|
|
@samp{SYNCID},
|
379 |
|
|
can have a value nearby @anchor{GREG-base}an initial value in place of its
|
380 |
|
|
second and third operands. Here, ``nearby'' is defined as within the
|
381 |
|
|
range 0@dots{}255 from the initial value of such an allocated register.
|
382 |
|
|
|
383 |
|
|
@smallexample
|
384 |
|
|
buffer1 BYTE 0,0,0,0,0
|
385 |
|
|
buffer2 BYTE 0,0,0,0,0
|
386 |
|
|
@dots{}
|
387 |
|
|
GREG buffer1
|
388 |
|
|
LDOU $42,buffer2
|
389 |
|
|
@end smallexample
|
390 |
|
|
In the example above, the @samp{Y} field of the @code{LDOUI} instruction
|
391 |
|
|
(LDOU with a constant Z) will be replaced with the global register
|
392 |
|
|
allocated for @samp{buffer1}, and the @samp{Z} field will have the value
|
393 |
|
|
5, the offset from @samp{buffer1} to @samp{buffer2}. The result is
|
394 |
|
|
equivalent to this code:
|
395 |
|
|
@smallexample
|
396 |
|
|
buffer1 BYTE 0,0,0,0,0
|
397 |
|
|
buffer2 BYTE 0,0,0,0,0
|
398 |
|
|
@dots{}
|
399 |
|
|
tmpreg GREG buffer1
|
400 |
|
|
LDOU $42,tmpreg,(buffer2-buffer1)
|
401 |
|
|
@end smallexample
|
402 |
|
|
|
403 |
|
|
Global registers allocated with this directive are allocated in order
|
404 |
|
|
higher-to-lower within a file. Other than that, the exact order of
|
405 |
|
|
register allocation and elimination is undefined. For example, the order
|
406 |
|
|
is undefined when more than one file with such directives are linked
|
407 |
|
|
together. With the options @samp{-x} and @samp{--linker-allocated-gregs},
|
408 |
|
|
@samp{GREG} directives for two-operand cases like the one mentioned above
|
409 |
|
|
can be omitted. Sufficient global registers will then be allocated by the
|
410 |
|
|
linker.
|
411 |
|
|
|
412 |
|
|
@item BYTE
|
413 |
|
|
@cindex assembler directive BYTE, MMIX
|
414 |
|
|
@cindex pseudo-op BYTE, MMIX
|
415 |
|
|
@cindex MMIX assembler directive BYTE
|
416 |
|
|
@cindex MMIX pseudo-op BYTE
|
417 |
|
|
|
418 |
|
|
@anchor{MMIX-byte}
|
419 |
|
|
The @samp{BYTE} directive takes a series of operands separated by a comma.
|
420 |
|
|
If an operand is a string (@pxref{Strings}), each character of that string
|
421 |
|
|
is emitted as a byte. Other operands must be constant expressions without
|
422 |
|
|
forward references, in the range 0@dots{}255. If you need operands having
|
423 |
|
|
expressions with forward references, use @samp{.byte} (@pxref{Byte}). An
|
424 |
|
|
operand can be omitted, defaulting to a zero value.
|
425 |
|
|
|
426 |
|
|
@item WYDE
|
427 |
|
|
@itemx TETRA
|
428 |
|
|
@itemx OCTA
|
429 |
|
|
@cindex assembler directive WYDE, MMIX
|
430 |
|
|
@cindex pseudo-op WYDE, MMIX
|
431 |
|
|
@cindex MMIX assembler directive WYDE
|
432 |
|
|
@cindex MMIX pseudo-op WYDE
|
433 |
|
|
@cindex assembler directive TETRA, MMIX
|
434 |
|
|
@cindex pseudo-op TETRA, MMIX
|
435 |
|
|
@cindex MMIX assembler directive TETRA
|
436 |
|
|
@cindex MMIX pseudo-op TETRA
|
437 |
|
|
@cindex assembler directive OCTA, MMIX
|
438 |
|
|
@cindex pseudo-op OCTA, MMIX
|
439 |
|
|
@cindex MMIX assembler directive OCTA
|
440 |
|
|
@cindex MMIX pseudo-op OCTA
|
441 |
|
|
|
442 |
|
|
@anchor{MMIX-constants}
|
443 |
|
|
The directives @samp{WYDE}, @samp{TETRA} and @samp{OCTA} emit constants of
|
444 |
|
|
two, four and eight bytes size respectively. Before anything else happens
|
445 |
|
|
for the directive, the current location is aligned to the respective
|
446 |
|
|
constant-size boundary. If a label is defined at the beginning of the
|
447 |
|
|
line, its value will be that after the alignment. A single operand can be
|
448 |
|
|
omitted, defaulting to a zero value emitted for the directive. Operands
|
449 |
|
|
can be expressed as strings (@pxref{Strings}), in which case each
|
450 |
|
|
character in the string is emitted as a separate constant of the size
|
451 |
|
|
indicated by the directive.
|
452 |
|
|
|
453 |
|
|
@item PREFIX
|
454 |
|
|
@cindex assembler directive PREFIX, MMIX
|
455 |
|
|
@cindex pseudo-op PREFIX, MMIX
|
456 |
|
|
@cindex MMIX assembler directive PREFIX
|
457 |
|
|
@cindex MMIX pseudo-op PREFIX
|
458 |
|
|
|
459 |
|
|
@anchor{MMIX-prefix}
|
460 |
|
|
The @samp{PREFIX} directive sets a symbol name prefix to be prepended to
|
461 |
|
|
all symbols (except local symbols, @pxref{MMIX-Symbols}), that are not
|
462 |
|
|
prefixed with @samp{:}, until the next @samp{PREFIX} directive. Such
|
463 |
|
|
prefixes accumulate. For example,
|
464 |
|
|
@smallexample
|
465 |
|
|
PREFIX a
|
466 |
|
|
PREFIX b
|
467 |
|
|
c IS 0
|
468 |
|
|
@end smallexample
|
469 |
|
|
defines a symbol @samp{abc} with the value 0.
|
470 |
|
|
|
471 |
|
|
@item BSPEC
|
472 |
|
|
@itemx ESPEC
|
473 |
|
|
@cindex assembler directive BSPEC, MMIX
|
474 |
|
|
@cindex pseudo-op BSPEC, MMIX
|
475 |
|
|
@cindex MMIX assembler directive BSPEC
|
476 |
|
|
@cindex MMIX pseudo-op BSPEC
|
477 |
|
|
@cindex assembler directive ESPEC, MMIX
|
478 |
|
|
@cindex pseudo-op ESPEC, MMIX
|
479 |
|
|
@cindex MMIX assembler directive ESPEC
|
480 |
|
|
@cindex MMIX pseudo-op ESPEC
|
481 |
|
|
|
482 |
|
|
@anchor{MMIX-spec}
|
483 |
|
|
A pair of @samp{BSPEC} and @samp{ESPEC} directives delimit a section of
|
484 |
|
|
special contents (without specified semantics). Example:
|
485 |
|
|
@smallexample
|
486 |
|
|
BSPEC 42
|
487 |
|
|
TETRA 1,2,3
|
488 |
|
|
ESPEC
|
489 |
|
|
@end smallexample
|
490 |
|
|
The single operand to @samp{BSPEC} must be number in the range
|
491 |
|
|
0@dots{}255. The @samp{BSPEC} number 80 is used by the GNU binutils
|
492 |
|
|
implementation.
|
493 |
|
|
@end table
|
494 |
|
|
|
495 |
|
|
@node MMIX-mmixal
|
496 |
|
|
@section Differences to @code{mmixal}
|
497 |
|
|
@cindex mmixal differences
|
498 |
|
|
@cindex differences, mmixal
|
499 |
|
|
|
500 |
|
|
The binutils @code{@value{AS}} and @code{@value{LD}} combination has a few
|
501 |
|
|
differences in function compared to @code{mmixal} (@pxref{mmixsite}).
|
502 |
|
|
|
503 |
|
|
The replacement of a symbol with a GREG-allocated register
|
504 |
|
|
(@pxref{GREG-base}) is not handled the exactly same way in
|
505 |
|
|
@code{@value{AS}} as in @code{mmixal}. This is apparent in the
|
506 |
|
|
@code{mmixal} example file @code{inout.mms}, where different registers
|
507 |
|
|
with different offsets, eventually yielding the same address, are used in
|
508 |
|
|
the first instruction. This type of difference should however not affect
|
509 |
|
|
the function of any program unless it has specific assumptions about the
|
510 |
|
|
allocated register number.
|
511 |
|
|
|
512 |
|
|
Line numbers (in the @samp{mmo} object format) are currently not
|
513 |
|
|
supported.
|
514 |
|
|
|
515 |
|
|
Expression operator precedence is not that of mmixal: operator precedence
|
516 |
|
|
is that of the C programming language. It's recommended to use
|
517 |
|
|
parentheses to explicitly specify wanted operator precedence whenever more
|
518 |
|
|
than one type of operators are used.
|
519 |
|
|
|
520 |
|
|
The serialize unary operator @code{&}, the fractional division operator
|
521 |
|
|
@samp{//}, the logical not operator @code{!} and the modulus operator
|
522 |
|
|
@samp{%} are not available.
|
523 |
|
|
|
524 |
|
|
Symbols are not global by default, unless the option
|
525 |
|
|
@samp{--globalize-symbols} is passed. Use the @samp{.global} directive to
|
526 |
|
|
globalize symbols (@pxref{Global}).
|
527 |
|
|
|
528 |
|
|
Operand syntax is a bit stricter with @code{@value{AS}} than
|
529 |
|
|
@code{mmixal}. For example, you can't say @code{addu 1,2,3}, instead you
|
530 |
|
|
must write @code{addu $1,$2,3}.
|
531 |
|
|
|
532 |
|
|
You can't LOC to a lower address than those already visited
|
533 |
|
|
(i.e., ``backwards'').
|
534 |
|
|
|
535 |
|
|
A LOC directive must come before any emitted code.
|
536 |
|
|
|
537 |
|
|
Predefined symbols are visible as file-local symbols after use. (In the
|
538 |
|
|
ELF file, that is---the linked mmo file has no notion of a file-local
|
539 |
|
|
symbol.)
|
540 |
|
|
|
541 |
|
|
Some mapping of constant expressions to sections in LOC expressions is
|
542 |
|
|
attempted, but that functionality is easily confused and should be avoided
|
543 |
|
|
unless compatibility with @code{mmixal} is required. A LOC expression to
|
544 |
|
|
@samp{0x2000000000000000} or higher, maps to the @samp{.data} section and
|
545 |
|
|
lower addresses map to the @samp{.text} section (@pxref{MMIX-loc}).
|
546 |
|
|
|
547 |
|
|
The code and data areas are each contiguous. Sparse programs with
|
548 |
|
|
far-away LOC directives will take up the same amount of space as a
|
549 |
|
|
contiguous program with zeros filled in the gaps between the LOC
|
550 |
|
|
directives. If you need sparse programs, you might try and get the wanted
|
551 |
|
|
effect with a linker script and splitting up the code parts into sections
|
552 |
|
|
(@pxref{Section}). Assembly code for this, to be compatible with
|
553 |
|
|
@code{mmixal}, would look something like:
|
554 |
|
|
@smallexample
|
555 |
|
|
.if 0
|
556 |
|
|
LOC away_expression
|
557 |
|
|
.else
|
558 |
|
|
.section away,"ax"
|
559 |
|
|
.fi
|
560 |
|
|
@end smallexample
|
561 |
|
|
@code{@value{AS}} will not execute the LOC directive and @code{mmixal}
|
562 |
|
|
ignores the lines with @code{.}. This construct can be used generally to
|
563 |
|
|
help compatibility.
|
564 |
|
|
|
565 |
|
|
Symbols can't be defined twice--not even to the same value.
|
566 |
|
|
|
567 |
|
|
Instruction mnemonics are recognized case-insensitive, though the
|
568 |
|
|
@samp{IS} and @samp{GREG} pseudo-operations must be specified in
|
569 |
|
|
upper-case characters.
|
570 |
|
|
|
571 |
|
|
There's no unicode support.
|
572 |
|
|
|
573 |
|
|
The following is a list of programs in @samp{mmix.tar.gz}, available at
|
574 |
|
|
@url{http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html}, last
|
575 |
|
|
checked with the version dated 2001-08-25 (md5sum
|
576 |
|
|
c393470cfc86fac040487d22d2bf0172) that assemble with @code{mmixal} but do
|
577 |
|
|
not assemble with @code{@value{AS}}:
|
578 |
|
|
|
579 |
|
|
@table @code
|
580 |
|
|
@item silly.mms
|
581 |
|
|
LOC to a previous address.
|
582 |
|
|
@item sim.mms
|
583 |
|
|
Redefines symbol @samp{Done}.
|
584 |
|
|
@item test.mms
|
585 |
|
|
Uses the serial operator @samp{&}.
|
586 |
|
|
@end table
|