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