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