~ubuntu-branches/ubuntu/utopic/binutils-arm64-cross/utopic

« back to all changes in this revision

Viewing changes to binutils-2.23.52.20130611/gas/doc/c-mmix.texi

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-06-20 17:38:09 UTC
  • Revision ID: package-import@ubuntu.com-20130620173809-app8lzgvymy5fg6c
Tags: 0.7
Build-depend on binutils-source (>= 2.23.52.20130620-1~).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@c Copyright 2001, 2002, 2003, 2006, 2011 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.  If a @samp{#} appears at the start of a line the whole line is
 
176
treated as a comment, but the line can also act as a logical line
 
177
number directive (@pxref{Comments}) or a preprocessor control command
 
178
(@pxref{Preprocessing}).
 
179
 
 
180
Two other characters, @samp{%} and @samp{!}, each start a comment anywhere
 
181
on the line.  Thus you can't use the @samp{modulus} and @samp{not}
 
182
operators in expressions normally associated with these two characters.
 
183
 
 
184
A @samp{;} is a line separator, treated as a new-line, so separate
 
185
instructions can be specified on a single line.
 
186
 
 
187
@node MMIX-Symbols
 
188
@subsection Symbols
 
189
The character @samp{:} is permitted in identifiers.  There are two
 
190
exceptions to it being treated as any other symbol character: if a symbol
 
191
begins with @samp{:}, it means that the symbol is in the global namespace
 
192
and that the current prefix should not be prepended to that symbol
 
193
(@pxref{MMIX-prefix}).  The @samp{:} is then not considered part of the
 
194
symbol.  For a symbol in the label position (first on a line), a @samp{:}
 
195
at the end of a symbol is silently stripped off.  A label is permitted,
 
196
but not required, to be followed by a @samp{:}, as with many other
 
197
assembly formats.
 
198
 
 
199
The character @samp{@@} in an expression, is a synonym for @samp{.}, the
 
200
current location.
 
201
 
 
202
In addition to the common forward and backward local symbol formats
 
203
(@pxref{Symbol Names}), they can be specified with upper-case @samp{B} and
 
204
@samp{F}, as in @samp{8B} and @samp{9F}.  A local label defined for the
 
205
current position is written with a @samp{H} appended to the number:
 
206
@smallexample
 
207
3H LDB $0,$1,2
 
208
@end smallexample
 
209
This and traditional local-label formats cannot be mixed: a label must be
 
210
defined and referred to using the same format.
 
211
 
 
212
There's a minor caveat: just as for the ordinary local symbols, the local
 
213
symbols are translated into ordinary symbols using control characters are
 
214
to hide the ordinal number of the symbol.  Unfortunately, these symbols
 
215
are not translated back in error messages.  Thus you may see confusing
 
216
error messages when local symbols are used.  Control characters
 
217
@samp{\003} (control-C) and @samp{\004} (control-D) are used for the
 
218
MMIX-specific local-symbol syntax.
 
219
 
 
220
The symbol @samp{Main} is handled specially; it is always global.
 
221
 
 
222
By defining the symbols @samp{__.MMIX.start..text} and
 
223
@samp{__.MMIX.start..data}, the address of respectively the @samp{.text}
 
224
and @samp{.data} segments of the final program can be defined, though when
 
225
linking more than one object file, the code or data in the object file
 
226
containing the symbol is not guaranteed to be start at that position; just
 
227
the final executable.  @xref{MMIX-loc}.
 
228
 
 
229
@node MMIX-Regs
 
230
@subsection Register names
 
231
@cindex register names, MMIX
 
232
@cindex MMIX register names
 
233
 
 
234
Local and global registers are specified as @samp{$0} to @samp{$255}.
 
235
The recognized special register names are @samp{rJ}, @samp{rA}, @samp{rB},
 
236
@samp{rC}, @samp{rD}, @samp{rE}, @samp{rF}, @samp{rG}, @samp{rH},
 
237
@samp{rI}, @samp{rK}, @samp{rL}, @samp{rM}, @samp{rN}, @samp{rO},
 
238
@samp{rP}, @samp{rQ}, @samp{rR}, @samp{rS}, @samp{rT}, @samp{rU},
 
239
@samp{rV}, @samp{rW}, @samp{rX}, @samp{rY}, @samp{rZ}, @samp{rBB},
 
240
@samp{rTT}, @samp{rWW}, @samp{rXX}, @samp{rYY} and @samp{rZZ}.  A leading
 
241
@samp{:} is optional for special register names.
 
242
 
 
243
Local and global symbols can be equated to register names and used in
 
244
place of ordinary registers.
 
245
 
 
246
Similarly for special registers, local and global symbols can be used.
 
247
Also, symbols equated from numbers and constant expressions are allowed in
 
248
place of a special register, except when either of the options
 
249
@code{--no-predefined-syms} and @code{--fixed-special-register-names} are
 
250
specified.  Then only the special register names above are allowed for the
 
251
instructions having a special register operand; @code{GET} and @code{PUT}.
 
252
 
 
253
@node MMIX-Pseudos
 
254
@subsection Assembler Directives
 
255
@cindex assembler directives, MMIX
 
256
@cindex pseudo-ops, MMIX
 
257
@cindex MMIX assembler directives
 
258
@cindex MMIX pseudo-ops
 
259
 
 
260
@table @code
 
261
@item LOC
 
262
@cindex assembler directive LOC, MMIX
 
263
@cindex pseudo-op LOC, MMIX
 
264
@cindex MMIX assembler directive LOC
 
265
@cindex MMIX pseudo-op LOC
 
266
 
 
267
@anchor{MMIX-loc}
 
268
The @code{LOC} directive sets the current location to the value of the
 
269
operand field, which may include changing sections.  If the operand is a
 
270
constant, the section is set to either @code{.data} if the value is
 
271
@code{0x2000000000000000} or larger, else it is set to @code{.text}.
 
272
Within a section, the current location may only be changed to
 
273
monotonically higher addresses.  A LOC expression must be a previously
 
274
defined symbol or a ``pure'' constant.
 
275
 
 
276
An example, which sets the label @var{prev} to the current location, and
 
277
updates the current location to eight bytes forward:
 
278
@smallexample
 
279
prev LOC @@+8
 
280
@end smallexample
 
281
 
 
282
When a LOC has a constant as its operand, a symbol
 
283
@code{__.MMIX.start..text} or @code{__.MMIX.start..data} is defined
 
284
depending on the address as mentioned above.  Each such symbol is
 
285
interpreted as special by the linker, locating the section at that
 
286
address.  Note that if multiple files are linked, the first object file
 
287
with that section will be mapped to that address (not necessarily the file
 
288
with the LOC definition).
 
289
 
 
290
@item LOCAL
 
291
@cindex assembler directive LOCAL, MMIX
 
292
@cindex pseudo-op LOCAL, MMIX
 
293
@cindex MMIX assembler directive LOCAL
 
294
@cindex MMIX pseudo-op LOCAL
 
295
 
 
296
@anchor{MMIX-local}
 
297
Example:
 
298
@smallexample
 
299
 LOCAL external_symbol
 
300
 LOCAL 42
 
301
 .local asymbol
 
302
@end smallexample
 
303
 
 
304
This directive-operation generates a link-time assertion that the operand
 
305
does not correspond to a global register.  The operand is an expression
 
306
that at link-time resolves to a register symbol or a number.  A number is
 
307
treated as the register having that number.  There is one restriction on
 
308
the use of this directive: the pseudo-directive must be placed in a
 
309
section with contents, code or data.
 
310
 
 
311
@item IS
 
312
@cindex assembler directive IS, MMIX
 
313
@cindex pseudo-op IS, MMIX
 
314
@cindex MMIX assembler directive IS
 
315
@cindex MMIX pseudo-op IS
 
316
 
 
317
@anchor{MMIX-is}
 
318
The @code{IS} directive:
 
319
@smallexample
 
320
asymbol IS an_expression
 
321
@end smallexample
 
322
sets the symbol @samp{asymbol} to @samp{an_expression}.  A symbol may not
 
323
be set more than once using this directive.  Local labels may be set using
 
324
this directive, for example:
 
325
@smallexample
 
326
5H IS @@+4
 
327
@end smallexample
 
328
 
 
329
@item GREG
 
330
@cindex assembler directive GREG, MMIX
 
331
@cindex pseudo-op GREG, MMIX
 
332
@cindex MMIX assembler directive GREG
 
333
@cindex MMIX pseudo-op GREG
 
334
 
 
335
@anchor{MMIX-greg}
 
336
This directive reserves a global register, gives it an initial value and
 
337
optionally gives it a symbolic name.  Some examples:
 
338
 
 
339
@smallexample
 
340
areg GREG
 
341
breg GREG data_value
 
342
     GREG data_buffer
 
343
     .greg creg, another_data_value
 
344
@end smallexample
 
345
 
 
346
The symbolic register name can be used in place of a (non-special)
 
347
register.  If a value isn't provided, it defaults to zero.  Unless the
 
348
option @samp{--no-merge-gregs} is specified, non-zero registers allocated
 
349
with this directive may be eliminated by @code{@value{AS}}; another
 
350
register with the same value used in its place.
 
351
Any of the instructions
 
352
@samp{CSWAP},
 
353
@samp{GO},
 
354
@samp{LDA},
 
355
@samp{LDBU},
 
356
@samp{LDB},
 
357
@samp{LDHT},
 
358
@samp{LDOU},
 
359
@samp{LDO},
 
360
@samp{LDSF},
 
361
@samp{LDTU},
 
362
@samp{LDT},
 
363
@samp{LDUNC},
 
364
@samp{LDVTS},
 
365
@samp{LDWU},
 
366
@samp{LDW},
 
367
@samp{PREGO},
 
368
@samp{PRELD},
 
369
@samp{PREST},
 
370
@samp{PUSHGO},
 
371
@samp{STBU},
 
372
@samp{STB},
 
373
@samp{STCO},
 
374
@samp{STHT},
 
375
@samp{STOU},
 
376
@samp{STSF},
 
377
@samp{STTU},
 
378
@samp{STT},
 
379
@samp{STUNC},
 
380
@samp{SYNCD},
 
381
@samp{SYNCID},
 
382
can have a value nearby @anchor{GREG-base}an initial value in place of its
 
383
second and third operands.  Here, ``nearby'' is defined as within the
 
384
range 0@dots{}255 from the initial value of such an allocated register.
 
385
 
 
386
@smallexample
 
387
buffer1 BYTE 0,0,0,0,0
 
388
buffer2 BYTE 0,0,0,0,0
 
389
 @dots{}
 
390
 GREG buffer1
 
391
 LDOU $42,buffer2
 
392
@end smallexample
 
393
In the example above, the @samp{Y} field of the @code{LDOUI} instruction
 
394
(LDOU with a constant Z) will be replaced with the global register
 
395
allocated for @samp{buffer1}, and the @samp{Z} field will have the value
 
396
5, the offset from @samp{buffer1} to @samp{buffer2}.  The result is
 
397
equivalent to this code:
 
398
@smallexample
 
399
buffer1 BYTE 0,0,0,0,0
 
400
buffer2 BYTE 0,0,0,0,0
 
401
 @dots{}
 
402
tmpreg GREG buffer1
 
403
 LDOU $42,tmpreg,(buffer2-buffer1)
 
404
@end smallexample
 
405
 
 
406
Global registers allocated with this directive are allocated in order
 
407
higher-to-lower within a file.  Other than that, the exact order of
 
408
register allocation and elimination is undefined.  For example, the order
 
409
is undefined when more than one file with such directives are linked
 
410
together.  With the options @samp{-x} and @samp{--linker-allocated-gregs},
 
411
@samp{GREG} directives for two-operand cases like the one mentioned above
 
412
can be omitted.  Sufficient global registers will then be allocated by the
 
413
linker.
 
414
 
 
415
@item BYTE
 
416
@cindex assembler directive BYTE, MMIX
 
417
@cindex pseudo-op BYTE, MMIX
 
418
@cindex MMIX assembler directive BYTE
 
419
@cindex MMIX pseudo-op BYTE
 
420
 
 
421
@anchor{MMIX-byte}
 
422
The @samp{BYTE} directive takes a series of operands separated by a comma.
 
423
If an operand is a string (@pxref{Strings}), each character of that string
 
424
is emitted as a byte.  Other operands must be constant expressions without
 
425
forward references, in the range 0@dots{}255.  If you need operands having
 
426
expressions with forward references, use @samp{.byte} (@pxref{Byte}).  An
 
427
operand can be omitted, defaulting to a zero value.
 
428
 
 
429
@item WYDE
 
430
@itemx TETRA
 
431
@itemx OCTA
 
432
@cindex assembler directive WYDE, MMIX
 
433
@cindex pseudo-op WYDE, MMIX
 
434
@cindex MMIX assembler directive WYDE
 
435
@cindex MMIX pseudo-op WYDE
 
436
@cindex assembler directive TETRA, MMIX
 
437
@cindex pseudo-op TETRA, MMIX
 
438
@cindex MMIX assembler directive TETRA
 
439
@cindex MMIX pseudo-op TETRA
 
440
@cindex assembler directive OCTA, MMIX
 
441
@cindex pseudo-op OCTA, MMIX
 
442
@cindex MMIX assembler directive OCTA
 
443
@cindex MMIX pseudo-op OCTA
 
444
 
 
445
@anchor{MMIX-constants}
 
446
The directives @samp{WYDE}, @samp{TETRA} and @samp{OCTA} emit constants of
 
447
two, four and eight bytes size respectively.  Before anything else happens
 
448
for the directive, the current location is aligned to the respective
 
449
constant-size boundary.  If a label is defined at the beginning of the
 
450
line, its value will be that after the alignment.  A single operand can be
 
451
omitted, defaulting to a zero value emitted for the directive.  Operands
 
452
can be expressed as strings (@pxref{Strings}), in which case each
 
453
character in the string is emitted as a separate constant of the size
 
454
indicated by the directive.
 
455
 
 
456
@item PREFIX
 
457
@cindex assembler directive PREFIX, MMIX
 
458
@cindex pseudo-op PREFIX, MMIX
 
459
@cindex MMIX assembler directive PREFIX
 
460
@cindex MMIX pseudo-op PREFIX
 
461
 
 
462
@anchor{MMIX-prefix}
 
463
The @samp{PREFIX} directive sets a symbol name prefix to be prepended to
 
464
all symbols (except local symbols, @pxref{MMIX-Symbols}), that are not
 
465
prefixed with @samp{:}, until the next @samp{PREFIX} directive.  Such
 
466
prefixes accumulate.  For example,
 
467
@smallexample
 
468
 PREFIX a
 
469
 PREFIX b
 
470
c IS 0
 
471
@end smallexample
 
472
defines a symbol @samp{abc} with the value 0.
 
473
 
 
474
@item BSPEC
 
475
@itemx ESPEC
 
476
@cindex assembler directive BSPEC, MMIX
 
477
@cindex pseudo-op BSPEC, MMIX
 
478
@cindex MMIX assembler directive BSPEC
 
479
@cindex MMIX pseudo-op BSPEC
 
480
@cindex assembler directive ESPEC, MMIX
 
481
@cindex pseudo-op ESPEC, MMIX
 
482
@cindex MMIX assembler directive ESPEC
 
483
@cindex MMIX pseudo-op ESPEC
 
484
 
 
485
@anchor{MMIX-spec}
 
486
A pair of @samp{BSPEC} and @samp{ESPEC} directives delimit a section of
 
487
special contents (without specified semantics).  Example:
 
488
@smallexample
 
489
 BSPEC 42
 
490
 TETRA 1,2,3
 
491
 ESPEC
 
492
@end smallexample
 
493
The single operand to @samp{BSPEC} must be number in the range
 
494
0@dots{}255.  The @samp{BSPEC} number 80 is used by the GNU binutils
 
495
implementation.
 
496
@end table
 
497
 
 
498
@node MMIX-mmixal
 
499
@section Differences to @code{mmixal}
 
500
@cindex mmixal differences
 
501
@cindex differences, mmixal
 
502
 
 
503
The binutils @code{@value{AS}} and @code{@value{LD}} combination has a few
 
504
differences in function compared to @code{mmixal} (@pxref{mmixsite}).
 
505
 
 
506
The replacement of a symbol with a GREG-allocated register
 
507
(@pxref{GREG-base}) is not handled the exactly same way in
 
508
@code{@value{AS}} as in @code{mmixal}.  This is apparent in the
 
509
@code{mmixal} example file @code{inout.mms}, where different registers
 
510
with different offsets, eventually yielding the same address, are used in
 
511
the first instruction.  This type of difference should however not affect
 
512
the function of any program unless it has specific assumptions about the
 
513
allocated register number.
 
514
 
 
515
Line numbers (in the @samp{mmo} object format) are currently not
 
516
supported.
 
517
 
 
518
Expression operator precedence is not that of mmixal: operator precedence
 
519
is that of the C programming language.  It's recommended to use
 
520
parentheses to explicitly specify wanted operator precedence whenever more
 
521
than one type of operators are used.
 
522
 
 
523
The serialize unary operator @code{&}, the fractional division operator
 
524
@samp{//}, the logical not operator @code{!} and the modulus operator
 
525
@samp{%} are not available.
 
526
 
 
527
Symbols are not global by default, unless the option
 
528
@samp{--globalize-symbols} is passed.  Use the @samp{.global} directive to
 
529
globalize symbols (@pxref{Global}).
 
530
 
 
531
Operand syntax is a bit stricter with @code{@value{AS}} than
 
532
@code{mmixal}.  For example, you can't say @code{addu 1,2,3}, instead you
 
533
must write @code{addu $1,$2,3}.
 
534
 
 
535
You can't LOC to a lower address than those already visited
 
536
(i.e., ``backwards'').
 
537
 
 
538
A LOC directive must come before any emitted code.
 
539
 
 
540
Predefined symbols are visible as file-local symbols after use.  (In the
 
541
ELF file, that is---the linked mmo file has no notion of a file-local
 
542
symbol.)
 
543
 
 
544
Some mapping of constant expressions to sections in LOC expressions is
 
545
attempted, but that functionality is easily confused and should be avoided
 
546
unless compatibility with @code{mmixal} is required.  A LOC expression to
 
547
@samp{0x2000000000000000} or higher, maps to the @samp{.data} section and
 
548
lower addresses map to the @samp{.text} section (@pxref{MMIX-loc}).
 
549
 
 
550
The code and data areas are each contiguous.  Sparse programs with
 
551
far-away LOC directives will take up the same amount of space as a
 
552
contiguous program with zeros filled in the gaps between the LOC
 
553
directives.  If you need sparse programs, you might try and get the wanted
 
554
effect with a linker script and splitting up the code parts into sections
 
555
(@pxref{Section}).  Assembly code for this, to be compatible with
 
556
@code{mmixal}, would look something like:
 
557
@smallexample
 
558
 .if 0
 
559
 LOC away_expression
 
560
 .else
 
561
 .section away,"ax"
 
562
 .fi
 
563
@end smallexample
 
564
@code{@value{AS}} will not execute the LOC directive and @code{mmixal}
 
565
ignores the lines with @code{.}.  This construct can be used generally to
 
566
help compatibility.
 
567
 
 
568
Symbols can't be defined twice--not even to the same value.
 
569
 
 
570
Instruction mnemonics are recognized case-insensitive, though the
 
571
@samp{IS} and @samp{GREG} pseudo-operations must be specified in
 
572
upper-case characters.
 
573
 
 
574
There's no unicode support.
 
575
 
 
576
The following is a list of programs in @samp{mmix.tar.gz}, available at
 
577
@url{http://www-cs-faculty.stanford.edu/~knuth/mmix-news.html}, last
 
578
checked with the version dated 2001-08-25 (md5sum
 
579
c393470cfc86fac040487d22d2bf0172) that assemble with @code{mmixal} but do
 
580
not assemble with @code{@value{AS}}:
 
581
 
 
582
@table @code
 
583
@item silly.mms
 
584
LOC to a previous address.
 
585
@item sim.mms
 
586
Redefines symbol @samp{Done}.
 
587
@item test.mms
 
588
Uses the serial operator @samp{&}.
 
589
@end table