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