You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
7.0 KiB
HTML
148 lines
7.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- This file documents the GNU Assembler "as".
|
|
|
|
Copyright (C) 1991-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3
|
|
or any later version published by the Free Software Foundation;
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
Back-Cover Texts. A copy of the license is included in the
|
|
section entitled "GNU Free Documentation License".
|
|
-->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Sub-Sections (Using as)</title>
|
|
|
|
<meta name="description" content="Sub-Sections (Using as)">
|
|
<meta name="keywords" content="Sub-Sections (Using as)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Sections.html#Sections" rel="up" title="Sections">
|
|
<link href="bss.html#bss" rel="next" title="bss">
|
|
<link href="As-Sections.html#As-Sections" rel="prev" title="As Sections">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Sub_002dSections"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="bss.html#bss" accesskey="n" rel="next">bss</a>, Previous: <a href="As-Sections.html#As-Sections" accesskey="p" rel="prev">As Sections</a>, Up: <a href="Sections.html#Sections" accesskey="u" rel="up">Sections</a> [<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>
|
|
</div>
|
|
<hr>
|
|
<a name="Sub_002dSections-1"></a>
|
|
<h3 class="section">4.4 Sub-Sections</h3>
|
|
|
|
<a name="index-numbered-subsections"></a>
|
|
<a name="index-grouping-data"></a>
|
|
<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 <em>subsections</em> 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 ‘<samp>.text 0</samp>’ before each
|
|
section of code being output, and a ‘<samp>.text 1</samp>’ before each group of
|
|
constants being output.
|
|
</p>
|
|
<p>Subsections are optional. If you do not use subsections, everything
|
|
goes in subsection number zero.
|
|
</p>
|
|
<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>
|
|
<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>
|
|
<p>To specify which subsection you want subsequent statements assembled
|
|
into, use a numeric argument to specify it, in a ‘<samp>.text
|
|
<var>expression</var></samp>’ or a ‘<samp>.data <var>expression</var></samp>’ statement.
|
|
When generating COFF output, you
|
|
can also use an extra subsection
|
|
argument with arbitrary named sections: ‘<samp>.section <var>name</var>,
|
|
<var>expression</var></samp>’.
|
|
When generating ELF output, you
|
|
can also use the <code>.subsection</code> directive (see <a href="SubSection.html#SubSection">SubSection</a>)
|
|
to specify a subsection: ‘<samp>.subsection <var>expression</var></samp>’.
|
|
<var>Expression</var> should be an absolute expression
|
|
(see <a href="Expressions.html#Expressions">Expressions</a>). If you just say ‘<samp>.text</samp>’ then ‘<samp>.text 0</samp>’
|
|
is assumed. Likewise ‘<samp>.data</samp>’ means ‘<samp>.data 0</samp>’. Assembly
|
|
begins in <code>text 0</code>. For instance:
|
|
</p><div class="smallexample">
|
|
<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></div>
|
|
|
|
<p>Each section has a <em>location counter</em> 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 <em>active</em> location counter.
|
|
</p>
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="bss.html#bss" accesskey="n" rel="next">bss</a>, Previous: <a href="As-Sections.html#As-Sections" accesskey="p" rel="prev">As Sections</a>, Up: <a href="Sections.html#Sections" accesskey="u" rel="up">Sections</a> [<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>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|