Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

131 rinda
6.2KB

  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 Small Data (Using as)</title>
  16. <meta name="description" content="MIPS Small Data (Using as)">
  17. <meta name="keywords" content="MIPS Small Data (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-ISA.html#MIPS-ISA" rel="next" title="MIPS ISA">
  26. <link href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" rel="prev" title="MIPS Symbol Sizes">
  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-Small-Data"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="MIPS-ISA.html#MIPS-ISA" accesskey="n" rel="next">MIPS ISA</a>, Previous: <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" accesskey="p" rel="prev">MIPS Symbol Sizes</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="Controlling-the-use-of-small-data-accesses"></a>
  63. <h4 class="subsection">9.27.4 Controlling the use of small data accesses</h4>
  64. <a name="index-small-data_002c-MIPS"></a>
  65. <a name="index-gp-register_002c-MIPS"></a>
  66. <p>It often takes several instructions to load the address of a symbol.
  67. For example, when &lsquo;<samp>addr</samp>&rsquo; is a 32-bit symbol, the non-PIC expansion
  68. of &lsquo;<samp>dla $4,addr</samp>&rsquo; is usually:
  69. </p>
  70. <div class="smallexample">
  71. <pre class="smallexample">lui $4,%hi(addr)
  72. daddiu $4,$4,%lo(addr)
  73. </pre></div>
  74. <p>The sequence is much longer when &lsquo;<samp>addr</samp>&rsquo; is a 64-bit symbol.
  75. See <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes">Directives to override the size of symbols</a>.
  76. </p>
  77. <p>In order to cut down on this overhead, most embedded MIPS systems
  78. set aside a 64-kilobyte &ldquo;small data&rdquo; area and guarantee that all
  79. data of size <var>n</var> and smaller will be placed in that area.
  80. The limit <var>n</var> is passed to both the assembler and the linker
  81. using the command-line option <samp>-G <var>n</var></samp>, see <a href="MIPS-Options.html#MIPS-Options">Assembler options</a>. Note that the same value of <var>n</var> must be used
  82. when linking and when assembling all input files to the link; any
  83. inconsistency could cause a relocation overflow error.
  84. </p>
  85. <p>The size of an object in the <code>.bss</code> section is set by the
  86. <code>.comm</code> or <code>.lcomm</code> directive that defines it. The size of
  87. an external object may be set with the <code>.extern</code> directive. For
  88. example, &lsquo;<samp>.extern sym,4</samp>&rsquo; declares that the object at <code>sym</code>
  89. is 4 bytes in length, while leaving <code>sym</code> otherwise undefined.
  90. </p>
  91. <p>When no <samp>-G</samp> option is given, the default limit is 8 bytes.
  92. The option <samp>-G 0</samp> prevents any data from being automatically
  93. classified as small.
  94. </p>
  95. <p>It is also possible to mark specific objects as small by putting them
  96. in the special sections <code>.sdata</code> and <code>.sbss</code>, which are
  97. &ldquo;small&rdquo; counterparts of <code>.data</code> and <code>.bss</code> respectively.
  98. The toolchain will treat such data as small regardless of the
  99. <samp>-G</samp> setting.
  100. </p>
  101. <p>On startup, systems that support a small data area are expected to
  102. initialize register <code>$28</code>, also known as <code>$gp</code>, in such a
  103. way that small data can be accessed using a 16-bit offset from that
  104. register. For example, when &lsquo;<samp>addr</samp>&rsquo; is small data,
  105. the &lsquo;<samp>dla $4,addr</samp>&rsquo; instruction above is equivalent to:
  106. </p>
  107. <div class="smallexample">
  108. <pre class="smallexample">daddiu $4,$28,%gp_rel(addr)
  109. </pre></div>
  110. <p>Small data is not supported for SVR4-style PIC.
  111. </p>
  112. <hr>
  113. <div class="header">
  114. <p>
  115. Next: <a href="MIPS-ISA.html#MIPS-ISA" accesskey="n" rel="next">MIPS ISA</a>, Previous: <a href="MIPS-Symbol-Sizes.html#MIPS-Symbol-Sizes" accesskey="p" rel="prev">MIPS Symbol Sizes</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>
  116. </div>
  117. </body>
  118. </html>