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