Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

145 linhas
7.0KB

  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>MIPS Macros (Using as)</title>
  16. <meta name="description" content="MIPS Macros (Using as)">
  17. <meta name="keywords" content="MIPS Macros (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="MIPS_002dDependent.html#MIPS_002dDependent" rel="up" title="MIPS-Dependent">
  25. <link href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" rel="next" title="MIPS Symbol Sizes">
  26. <link href="MIPS-Options.html#MIPS-Options" rel="prev" title="MIPS Options">
  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="MIPS-Macros"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" accesskey="n" rel="next">MIPS Symbol Sizes</a>, Previous: <a href="MIPS-Options.html#MIPS-Options" accesskey="p" rel="prev">MIPS Options</a>, Up: <a href="MIPS_002dDependent.html#MIPS_002dDependent" accesskey="u" rel="up">MIPS-Dependent</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="High_002dlevel-assembly-macros"></a>
  63. <h4 class="subsection">9.27.2 High-level assembly macros</h4>
  64. <p>MIPS assemblers have traditionally provided a wider range of
  65. instructions than the MIPS architecture itself. These extra
  66. instructions are usually referred to as &ldquo;macro&rdquo; instructions
  67. <a name="DOCF2" href="#FOOT2"><sup>2</sup></a>.
  68. </p>
  69. <p>Some MIPS macro instructions extend an underlying architectural instruction
  70. while others are entirely new. An example of the former type is <code>and</code>,
  71. which allows the third operand to be either a register or an arbitrary
  72. immediate value. Examples of the latter type include <code>bgt</code>, which
  73. branches to the third operand when the first operand is greater than
  74. the second operand, and <code>ulh</code>, which implements an unaligned
  75. 2-byte load.
  76. </p>
  77. <p>One of the most common extensions provided by macros is to expand
  78. memory offsets to the full address range (32 or 64 bits) and to allow
  79. symbolic offsets such as &lsquo;<samp>my_data + 4</samp>&rsquo; to be used in place of
  80. integer constants. For example, the architectural instruction
  81. <code>lbu</code> allows only a signed 16-bit offset, whereas the macro
  82. <code>lbu</code> allows code such as &lsquo;<samp>lbu $4,array+32769($5)</samp>&rsquo;.
  83. The implementation of these symbolic offsets depends on several factors,
  84. such as whether the assembler is generating SVR4-style PIC (selected by
  85. <samp>-KPIC</samp>, see <a href="MIPS-Options.html#MIPS-Options">Assembler options</a>), the size of symbols
  86. (see <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes">Directives to override the size of symbols</a>),
  87. and the small data limit (see <a href="MIPS-Small-Data.html#MIPS-Small-Data">Controlling the use
  88. of small data accesses</a>).
  89. </p>
  90. <a name="index-_002eset-macro"></a>
  91. <a name="index-_002eset-nomacro"></a>
  92. <p>Sometimes it is undesirable to have one assembly instruction expand
  93. to several machine instructions. The directive <code>.set nomacro</code>
  94. tells the assembler to warn when this happens. <code>.set macro</code>
  95. restores the default behavior.
  96. </p>
  97. <a name="index-at-register_002c-MIPS"></a>
  98. <a name="index-_002eset-at_003dreg"></a>
  99. <p>Some macro instructions need a temporary register to store intermediate
  100. results. This register is usually <code>$1</code>, also known as <code>$at</code>,
  101. but it can be changed to any core register <var>reg</var> using
  102. <code>.set at=<var>reg</var></code>. Note that <code>$at</code> always refers
  103. to <code>$1</code> regardless of which register is being used as the
  104. temporary register.
  105. </p>
  106. <a name="index-_002eset-at"></a>
  107. <a name="index-_002eset-noat"></a>
  108. <p>Implicit uses of the temporary register in macros could interfere with
  109. explicit uses in the assembly code. The assembler therefore warns
  110. whenever it sees an explicit use of the temporary register. The directive
  111. <code>.set noat</code> silences this warning while <code>.set at</code> restores
  112. the default behavior. It is safe to use <code>.set noat</code> while
  113. <code>.set nomacro</code> is in effect since single-instruction macros
  114. never need a temporary register.
  115. </p>
  116. <p>Note that while the <small>GNU</small> assembler provides these macros for compatibility,
  117. it does not make any attempt to optimize them with the surrounding code.
  118. </p>
  119. <div class="footnote">
  120. <hr>
  121. <h4 class="footnotes-heading">Footnotes</h4>
  122. <h3><a name="FOOT2" href="#DOCF2">(2)</a></h3>
  123. <p>The term &ldquo;macro&rdquo; is somewhat overloaded here, since
  124. these macros have no relation to those defined by <code>.macro</code>,
  125. see <a href="Macro.html#Macro"><code>.macro</code></a>.</p>
  126. </div>
  127. <hr>
  128. <div class="header">
  129. <p>
  130. Next: <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" accesskey="n" rel="next">MIPS Symbol Sizes</a>, Previous: <a href="MIPS-Options.html#MIPS-Options" accesskey="p" rel="prev">MIPS Options</a>, Up: <a href="MIPS_002dDependent.html#MIPS_002dDependent" accesskey="u" rel="up">MIPS-Dependent</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>
  131. </div>
  132. </body>
  133. </html>