⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sub-sections.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Using as</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Using as">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

</head>

<body>

<div class="node">

<p>

Node:<a name="Sub-Sections">Sub-Sections</a>,

Next:<a rel="next" accesskey="n" href="bss.html#bss">bss</a>,

Previous:<a rel="previous" accesskey="p" href="As-Sections.html#As%20Sections">As Sections</a>,

Up:<a rel="up" accesskey="u" href="Sections.html#Sections">Sections</a>

<hr><br>

</div>



<h3 class="section">Sub-Sections</h3>



   <p>Assembled bytes

conventionally

fall into two sections: text and data. 

You may have separate groups of

data in named sections

that you want to end up near to each other in the object file, even though they

are not contiguous in the assembler source.  <code>as</code> allows you to

use <dfn>subsections</dfn> for this purpose.  Within each section, there can be

numbered subsections with values from 0 to 8192.  Objects assembled into the

same subsection go into the object file together with other objects in the same

subsection.  For example, a compiler might want to store constants in the text

section, but might not want to have them interspersed with the program being

assembled.  In this case, the compiler could issue a <code>.text 0</code> before each

section of code being output, and a <code>.text 1</code> before each group of

constants being output.



   <p>Subsections are optional.  If you do not use subsections, everything

goes in subsection number zero.



   <p>Each subsection is zero-padded up to a multiple of four bytes. 

(Subsections may be padded a different amount on different flavors

of <code>as</code>.)



   <p>Subsections appear in your object file in numeric order, lowest numbered

to highest.  (All this to be compatible with other people's assemblers.) 

The object file contains no representation of subsections; <code>ld</code> and

other programs that manipulate object files see no trace of them. 

They just see all your text subsections as a text section, and all your

data subsections as a data section.



   <p>To specify which subsection you want subsequent statements assembled

into, use a numeric argument to specify it, in a <code>.text

</code><var>expression</var><code></code> or a <code>.data </code><var>expression</var><code></code> statement. 

When generating COFF output, you

can also use an extra subsection

argument with arbitrary named sections: <code>.section </code><var>name</var><code>,

</code><var>expression</var><code></code>. 

<var>Expression</var> should be an absolute expression. 

(See <a href="Expressions.html#Expressions">Expressions</a>.)  If you just say <code>.text</code> then <code>.text 0</code>

is assumed.  Likewise <code>.data</code> means <code>.data 0</code>.  Assembly

begins in <code>text 0</code>.  For instance:

<pre class="smallexample">     .text 0     # The default subsection is text 0 anyway.

     .ascii "This lives in the first text subsection. *"

     .text 1

     .ascii "But this lives in the second text subsection."

     .data 0

     .ascii "This lives in the data section,"

     .ascii "in the first data subsection."

     .text 0

     .ascii "This lives in the first text section,"

     .ascii "immediately following the asterisk (*)."

     </pre>



   <p>Each section has a <dfn>location counter</dfn> incremented by one for every byte

assembled into that section.  Because subsections are merely a convenience

restricted to <code>as</code> there is no concept of a subsection location

counter.  There is no way to directly manipulate a location counter--but the

<code>.align</code> directive changes it, and any label definition captures its

current value.  The location counter of the section where statements are being

assembled is said to be the <dfn>active</dfn> location counter.



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -