You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MMIX_002dPseudos.html 14KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2020 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>MMIX-Pseudos (Using as)</title>
  16. <meta name="description" content="MMIX-Pseudos (Using as)">
  17. <meta name="keywords" content="MMIX-Pseudos (Using as)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="MMIX_002dSyntax.html#MMIX_002dSyntax" rel="up" title="MMIX-Syntax">
  25. <link href="MMIX_002dmmixal.html#MMIX_002dmmixal" rel="next" title="MMIX-mmixal">
  26. <link href="MMIX_002dRegs.html#MMIX_002dRegs" rel="prev" title="MMIX-Regs">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="MMIX_002dPseudos"></a>
  57. <div class="header">
  58. <p>
  59. Previous: <a href="MMIX_002dRegs.html#MMIX_002dRegs" accesskey="p" rel="prev">MMIX-Regs</a>, Up: <a href="MMIX_002dSyntax.html#MMIX_002dSyntax" accesskey="u" rel="up">MMIX-Syntax</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="Assembler-Directives-3"></a>
  63. <h4 class="subsubsection">9.28.3.4 Assembler Directives</h4>
  64. <a name="index-assembler-directives_002c-MMIX"></a>
  65. <a name="index-pseudo_002dops_002c-MMIX"></a>
  66. <a name="index-MMIX-assembler-directives"></a>
  67. <a name="index-MMIX-pseudo_002dops"></a>
  68. <dl compact="compact">
  69. <dt><code>LOC</code></dt>
  70. <dd><a name="index-assembler-directive-LOC_002c-MMIX"></a>
  71. <a name="index-pseudo_002dop-LOC_002c-MMIX"></a>
  72. <a name="index-MMIX-assembler-directive-LOC"></a>
  73. <a name="index-MMIX-pseudo_002dop-LOC"></a>
  74. <a name="MMIX_002dloc"></a><p>The <code>LOC</code> directive sets the current location to the value of the
  75. operand field, which may include changing sections. If the operand is a
  76. constant, the section is set to either <code>.data</code> if the value is
  77. <code>0x2000000000000000</code> or larger, else it is set to <code>.text</code>.
  78. Within a section, the current location may only be changed to
  79. monotonically higher addresses. A LOC expression must be a previously
  80. defined symbol or a &ldquo;pure&rdquo; constant.
  81. </p>
  82. <p>An example, which sets the label <var>prev</var> to the current location, and
  83. updates the current location to eight bytes forward:
  84. </p><div class="smallexample">
  85. <pre class="smallexample">prev LOC @+8
  86. </pre></div>
  87. <p>When a LOC has a constant as its operand, a symbol
  88. <code>__.MMIX.start..text</code> or <code>__.MMIX.start..data</code> is defined
  89. depending on the address as mentioned above. Each such symbol is
  90. interpreted as special by the linker, locating the section at that
  91. address. Note that if multiple files are linked, the first object file
  92. with that section will be mapped to that address (not necessarily the file
  93. with the LOC definition).
  94. </p>
  95. </dd>
  96. <dt><code>LOCAL</code></dt>
  97. <dd><a name="index-assembler-directive-LOCAL_002c-MMIX"></a>
  98. <a name="index-pseudo_002dop-LOCAL_002c-MMIX"></a>
  99. <a name="index-MMIX-assembler-directive-LOCAL"></a>
  100. <a name="index-MMIX-pseudo_002dop-LOCAL"></a>
  101. <a name="MMIX_002dlocal"></a><p>Example:
  102. </p><div class="smallexample">
  103. <pre class="smallexample"> LOCAL external_symbol
  104. LOCAL 42
  105. .local asymbol
  106. </pre></div>
  107. <p>This directive-operation generates a link-time assertion that the operand
  108. does not correspond to a global register. The operand is an expression
  109. that at link-time resolves to a register symbol or a number. A number is
  110. treated as the register having that number. There is one restriction on
  111. the use of this directive: the pseudo-directive must be placed in a
  112. section with contents, code or data.
  113. </p>
  114. </dd>
  115. <dt><code>IS</code></dt>
  116. <dd><a name="index-assembler-directive-IS_002c-MMIX"></a>
  117. <a name="index-pseudo_002dop-IS_002c-MMIX"></a>
  118. <a name="index-MMIX-assembler-directive-IS"></a>
  119. <a name="index-MMIX-pseudo_002dop-IS"></a>
  120. <a name="MMIX_002dis"></a><p>The <code>IS</code> directive:
  121. </p><div class="smallexample">
  122. <pre class="smallexample">asymbol IS an_expression
  123. </pre></div>
  124. <p>sets the symbol &lsquo;<samp>asymbol</samp>&rsquo; to &lsquo;<samp>an_expression</samp>&rsquo;. A symbol may not
  125. be set more than once using this directive. Local labels may be set using
  126. this directive, for example:
  127. </p><div class="smallexample">
  128. <pre class="smallexample">5H IS @+4
  129. </pre></div>
  130. </dd>
  131. <dt><code>GREG</code></dt>
  132. <dd><a name="index-assembler-directive-GREG_002c-MMIX"></a>
  133. <a name="index-pseudo_002dop-GREG_002c-MMIX"></a>
  134. <a name="index-MMIX-assembler-directive-GREG"></a>
  135. <a name="index-MMIX-pseudo_002dop-GREG"></a>
  136. <a name="MMIX_002dgreg"></a><p>This directive reserves a global register, gives it an initial value and
  137. optionally gives it a symbolic name. Some examples:
  138. </p>
  139. <div class="smallexample">
  140. <pre class="smallexample">areg GREG
  141. breg GREG data_value
  142. GREG data_buffer
  143. .greg creg, another_data_value
  144. </pre></div>
  145. <p>The symbolic register name can be used in place of a (non-special)
  146. register. If a value isn&rsquo;t provided, it defaults to zero. Unless the
  147. option &lsquo;<samp>--no-merge-gregs</samp>&rsquo; is specified, non-zero registers allocated
  148. with this directive may be eliminated by <code>as</code>; another
  149. register with the same value used in its place.
  150. Any of the instructions
  151. &lsquo;<samp>CSWAP</samp>&rsquo;,
  152. &lsquo;<samp>GO</samp>&rsquo;,
  153. &lsquo;<samp>LDA</samp>&rsquo;,
  154. &lsquo;<samp>LDBU</samp>&rsquo;,
  155. &lsquo;<samp>LDB</samp>&rsquo;,
  156. &lsquo;<samp>LDHT</samp>&rsquo;,
  157. &lsquo;<samp>LDOU</samp>&rsquo;,
  158. &lsquo;<samp>LDO</samp>&rsquo;,
  159. &lsquo;<samp>LDSF</samp>&rsquo;,
  160. &lsquo;<samp>LDTU</samp>&rsquo;,
  161. &lsquo;<samp>LDT</samp>&rsquo;,
  162. &lsquo;<samp>LDUNC</samp>&rsquo;,
  163. &lsquo;<samp>LDVTS</samp>&rsquo;,
  164. &lsquo;<samp>LDWU</samp>&rsquo;,
  165. &lsquo;<samp>LDW</samp>&rsquo;,
  166. &lsquo;<samp>PREGO</samp>&rsquo;,
  167. &lsquo;<samp>PRELD</samp>&rsquo;,
  168. &lsquo;<samp>PREST</samp>&rsquo;,
  169. &lsquo;<samp>PUSHGO</samp>&rsquo;,
  170. &lsquo;<samp>STBU</samp>&rsquo;,
  171. &lsquo;<samp>STB</samp>&rsquo;,
  172. &lsquo;<samp>STCO</samp>&rsquo;,
  173. &lsquo;<samp>STHT</samp>&rsquo;,
  174. &lsquo;<samp>STOU</samp>&rsquo;,
  175. &lsquo;<samp>STSF</samp>&rsquo;,
  176. &lsquo;<samp>STTU</samp>&rsquo;,
  177. &lsquo;<samp>STT</samp>&rsquo;,
  178. &lsquo;<samp>STUNC</samp>&rsquo;,
  179. &lsquo;<samp>SYNCD</samp>&rsquo;,
  180. &lsquo;<samp>SYNCID</samp>&rsquo;,
  181. can have a value nearby <a name="GREG_002dbase"></a>an initial value in place of its
  182. second and third operands. Here, &ldquo;nearby&rdquo; is defined as within the
  183. range 0&hellip;255 from the initial value of such an allocated register.
  184. </p>
  185. <div class="smallexample">
  186. <pre class="smallexample">buffer1 BYTE 0,0,0,0,0
  187. buffer2 BYTE 0,0,0,0,0
  188. &hellip;
  189. GREG buffer1
  190. LDOU $42,buffer2
  191. </pre></div>
  192. <p>In the example above, the &lsquo;<samp>Y</samp>&rsquo; field of the <code>LDOUI</code> instruction
  193. (LDOU with a constant Z) will be replaced with the global register
  194. allocated for &lsquo;<samp>buffer1</samp>&rsquo;, and the &lsquo;<samp>Z</samp>&rsquo; field will have the value
  195. 5, the offset from &lsquo;<samp>buffer1</samp>&rsquo; to &lsquo;<samp>buffer2</samp>&rsquo;. The result is
  196. equivalent to this code:
  197. </p><div class="smallexample">
  198. <pre class="smallexample">buffer1 BYTE 0,0,0,0,0
  199. buffer2 BYTE 0,0,0,0,0
  200. &hellip;
  201. tmpreg GREG buffer1
  202. LDOU $42,tmpreg,(buffer2-buffer1)
  203. </pre></div>
  204. <p>Global registers allocated with this directive are allocated in order
  205. higher-to-lower within a file. Other than that, the exact order of
  206. register allocation and elimination is undefined. For example, the order
  207. is undefined when more than one file with such directives are linked
  208. together. With the options &lsquo;<samp>-x</samp>&rsquo; and &lsquo;<samp>--linker-allocated-gregs</samp>&rsquo;,
  209. &lsquo;<samp>GREG</samp>&rsquo; directives for two-operand cases like the one mentioned above
  210. can be omitted. Sufficient global registers will then be allocated by the
  211. linker.
  212. </p>
  213. </dd>
  214. <dt><code>BYTE</code></dt>
  215. <dd><a name="index-assembler-directive-BYTE_002c-MMIX"></a>
  216. <a name="index-pseudo_002dop-BYTE_002c-MMIX"></a>
  217. <a name="index-MMIX-assembler-directive-BYTE"></a>
  218. <a name="index-MMIX-pseudo_002dop-BYTE"></a>
  219. <a name="MMIX_002dbyte"></a><p>The &lsquo;<samp>BYTE</samp>&rsquo; directive takes a series of operands separated by a comma.
  220. If an operand is a string (see <a href="Strings.html#Strings">Strings</a>), each character of that string
  221. is emitted as a byte. Other operands must be constant expressions without
  222. forward references, in the range 0&hellip;255. If you need operands having
  223. expressions with forward references, use &lsquo;<samp>.byte</samp>&rsquo; (see <a href="Byte.html#Byte">Byte</a>). An
  224. operand can be omitted, defaulting to a zero value.
  225. </p>
  226. </dd>
  227. <dt><code>WYDE</code></dt>
  228. <dt><code>TETRA</code></dt>
  229. <dt><code>OCTA</code></dt>
  230. <dd><a name="index-assembler-directive-WYDE_002c-MMIX"></a>
  231. <a name="index-pseudo_002dop-WYDE_002c-MMIX"></a>
  232. <a name="index-MMIX-assembler-directive-WYDE"></a>
  233. <a name="index-MMIX-pseudo_002dop-WYDE"></a>
  234. <a name="index-assembler-directive-TETRA_002c-MMIX"></a>
  235. <a name="index-pseudo_002dop-TETRA_002c-MMIX"></a>
  236. <a name="index-MMIX-assembler-directive-TETRA"></a>
  237. <a name="index-MMIX-pseudo_002dop-TETRA"></a>
  238. <a name="index-assembler-directive-OCTA_002c-MMIX"></a>
  239. <a name="index-pseudo_002dop-OCTA_002c-MMIX"></a>
  240. <a name="index-MMIX-assembler-directive-OCTA"></a>
  241. <a name="index-MMIX-pseudo_002dop-OCTA"></a>
  242. <a name="MMIX_002dconstants"></a><p>The directives &lsquo;<samp>WYDE</samp>&rsquo;, &lsquo;<samp>TETRA</samp>&rsquo; and &lsquo;<samp>OCTA</samp>&rsquo; emit constants of
  243. two, four and eight bytes size respectively. Before anything else happens
  244. for the directive, the current location is aligned to the respective
  245. constant-size boundary. If a label is defined at the beginning of the
  246. line, its value will be that after the alignment. A single operand can be
  247. omitted, defaulting to a zero value emitted for the directive. Operands
  248. can be expressed as strings (see <a href="Strings.html#Strings">Strings</a>), in which case each
  249. character in the string is emitted as a separate constant of the size
  250. indicated by the directive.
  251. </p>
  252. </dd>
  253. <dt><code>PREFIX</code></dt>
  254. <dd><a name="index-assembler-directive-PREFIX_002c-MMIX"></a>
  255. <a name="index-pseudo_002dop-PREFIX_002c-MMIX"></a>
  256. <a name="index-MMIX-assembler-directive-PREFIX"></a>
  257. <a name="index-MMIX-pseudo_002dop-PREFIX"></a>
  258. <a name="MMIX_002dprefix"></a><p>The &lsquo;<samp>PREFIX</samp>&rsquo; directive sets a symbol name prefix to be prepended to
  259. all symbols (except local symbols, see <a href="MMIX_002dSymbols.html#MMIX_002dSymbols">MMIX-Symbols</a>), that are not
  260. prefixed with &lsquo;<samp>:</samp>&rsquo;, until the next &lsquo;<samp>PREFIX</samp>&rsquo; directive. Such
  261. prefixes accumulate. For example,
  262. </p><div class="smallexample">
  263. <pre class="smallexample"> PREFIX a
  264. PREFIX b
  265. c IS 0
  266. </pre></div>
  267. <p>defines a symbol &lsquo;<samp>abc</samp>&rsquo; with the value 0.
  268. </p>
  269. </dd>
  270. <dt><code>BSPEC</code></dt>
  271. <dt><code>ESPEC</code></dt>
  272. <dd><a name="index-assembler-directive-BSPEC_002c-MMIX"></a>
  273. <a name="index-pseudo_002dop-BSPEC_002c-MMIX"></a>
  274. <a name="index-MMIX-assembler-directive-BSPEC"></a>
  275. <a name="index-MMIX-pseudo_002dop-BSPEC"></a>
  276. <a name="index-assembler-directive-ESPEC_002c-MMIX"></a>
  277. <a name="index-pseudo_002dop-ESPEC_002c-MMIX"></a>
  278. <a name="index-MMIX-assembler-directive-ESPEC"></a>
  279. <a name="index-MMIX-pseudo_002dop-ESPEC"></a>
  280. <a name="MMIX_002dspec"></a><p>A pair of &lsquo;<samp>BSPEC</samp>&rsquo; and &lsquo;<samp>ESPEC</samp>&rsquo; directives delimit a section of
  281. special contents (without specified semantics). Example:
  282. </p><div class="smallexample">
  283. <pre class="smallexample"> BSPEC 42
  284. TETRA 1,2,3
  285. ESPEC
  286. </pre></div>
  287. <p>The single operand to &lsquo;<samp>BSPEC</samp>&rsquo; must be number in the range
  288. 0&hellip;255. The &lsquo;<samp>BSPEC</samp>&rsquo; number 80 is used by the GNU binutils
  289. implementation.
  290. </p></dd>
  291. </dl>
  292. <hr>
  293. <div class="header">
  294. <p>
  295. Previous: <a href="MMIX_002dRegs.html#MMIX_002dRegs" accesskey="p" rel="prev">MMIX-Regs</a>, Up: <a href="MMIX_002dSyntax.html#MMIX_002dSyntax" accesskey="u" rel="up">MMIX-Syntax</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  296. </div>
  297. </body>
  298. </html>