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