Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
XENIX Programming as: Assembler Assembly Segments as assembles instruction and data statements in three segments, text, data, and bss. Segments allow division of instructions and data into separate physical segments in memory. A location counter keeps the current address within each segment during assembly and provides reference to the current instruction and data. Text, Data, and Bss Segments Every program is divided into at most three distinct segments of assembled code and data: the text segment, the data segment, and the bss segment. Each segment is reserved for a specific type of storage and receives different treat ment from the assembler and from the XENIX linker when the final program is created. The text segment is normally reserved for instructions but may also be used for data. Instructions in this segment are assembled, and the code is copied to the output file. Data definitions in this segment are also assembled and copied; the code is the value of the data item. The assembler does not separate the instruction and data code. If the instructions and data definitions are mixed within the source file, the resulting code is mixed within the output file. The data segment is reserved for data. The code is copied to a different part of the output file and receives different treat ment from the XENIX linker. The bss segment is reserved for uninitialized data only. Instructions or data definitions with initial values must not be given in this segment. The assembler counts the nu mber of bytes allocated for this segment and copies this count to the output file. It does not generate code. The text segment is implicitly defined at the start of every assembly. Thus, any instructions or data definitions given when no other segment is explicitly defined are copied to the text segment. To start a data or bss segment, you must use a .data or .bss directive. You can explicitly start the text segment with the .text directive (see the section "Segment Directives," later in this chapter). Unless otherwise specified, the first statement in the text segment is considered the program's entry point. In shared-text programs, the instructions and data in the text segment are write-protected; in nonshared-text programs, they are not. Instructions and data in the data segment are never write-protected. The bss segment is actually an extension of the data segment. It begins immediately after the data segment and is initialized to 0 at the start of program execution. 7-3
as: Assembler XENIX Programming The Location Counter The special symbol "dot" (.) is the location counter. Its value at any time is the offset from the current statement to the start of the current segment. Thus, it may be used in any statement to refer to the current location. The location counter actually has three different offsets, one for each type of segment. Only the offset of the current segment is ever accessible. The assembler increments the current offset after it processes each statement. It increments the offset by the number of bytes in the assembled code or allocated storage. The location counter can be assigned an explicit value if desired. Its value must not be decreased. If it is explicitly increased, the assembler generates enough null bytes of code to fill the gap between the last offset and the new offset. Statements A source program is composed of a sequence of statements. Statements are separated by newline characters. There are four kinds of statements: • Null statements • Expression statements • Assignment statements • Keyword statements The format for most 8086/286 assembly language source statements is [ /abe/field ] op-code [ operand-field ] [ comment ] Any kind of statement may be preceded by one or more labels. Labels There are two kinds of labels: name labels and numeric labels. A name label consists of an identifier followed by a colon (:). The effect of a name label is to assign the current value and type of the location counter to the name. An error is indicated in pass 1 if the name is already defined; an error is indicated in pass 2 if the value assigned changes the definition of the label. 7-4
- Page 81 and 82: SCCS: Source Code Control System XE
- Page 83 and 84: SCCS: Source Code Control System XE
- Page 85 and 86: SCCS: Source Code Control System XE
- Page 87 and 88: SCCS: Source Code Control System XE
- Page 89 and 90: SCCS: Source Code Control System XE
- Page 91 and 92: SCCS: Source Code Control System XE
- Page 93 and 94: SCCS: Source Code Control System XE
- Page 95 and 96: SCCS: Source Code Control System XE
- Page 98 and 99: CHAPTER 6 adb: PROGRAM DEBUGGER adb
- Page 100 and 101: XENIX Programming adb: Program Debu
- Page 102 and 103: XENIX Programming adb: Program Debu
- Page 104 and 105: XENIX Programming adb: Program Debu
- Page 106 and 107: XENIX Programming adb: Program Debu
- Page 108 and 109: XENIX Programming adb: Program Debu
- Page 110 and 111: XENIX Programming adb: Program Debu
- Page 112 and 113: XENIX Programming adb: Program Debu
- Page 114 and 115: XENIX Programming adb: Program Debu
- Page 116 and 117: XENIX Programming int fcnt,gcnt,hcn
- Page 118 and 119: XENIX Programming adb: Program Debu
- Page 120 and 121: XENIX Programming adb: Program Debu
- Page 122 and 123: XENIX Programming adb: Program Debu
- Page 124 and 125: XENIX Programming adb: Program Debu
- Page 126 and 127: XENIX Programming adb: Program Debu
- Page 128: XENIX Programming adb: Program Debu
- Page 131: as: A sse m bier XENIX Programming
- Page 135 and 136: as: Assembler XENIX Programming Key
- Page 137 and 138: as: Assembler The combination rules
- Page 139 and 140: as: Assembler XENIX Programming Ins
- Page 141 and 142: as: Assembler Initial Value Directi
- Page 143 and 144: as: Assembler XENIX Programming int
- Page 145 and 146: as: A sse m bier sub subb test test
- Page 147 and 148: as: Assembler XENIX Programming lnt
- Page 149 and 150: as: Assembler XENIX Programming lnt
- Page 151 and 152: as: Assembler XENIX Programming Imm
- Page 153 and 154: as: A sse m bier XENIX Programming
- Page 156 and 157: CHAPTER 8 csh : C SHEll The C shell
- Page 158 and 159: XENIX Programming csh: C Shell Some
- Page 160 and 161: XENIX Programm ing *w 32 * q % !c -
- Page 162 and 163: XENIX Programming csh: C Shell the
- Page 164 and 165: XENIX Programming csh: C Shell Usin
- Page 166 and 167: XENIX Programming csh: C Shell Usin
- Page 168 and 169: XENIX Programming csh: C Shell The
- Page 170 and 171: XENIX Programming csh: C Shell Note
- Page 172 and 173: XENIX Programming switch ( string c
- Page 174 and 175: XENIX Programming csh: C Shell Star
- Page 176 and 177: XENIX Programming csh: C Shell Spec
- Page 178 and 179: CHAPTER 9 lex : LEXICAL ANA LYZER G
- Page 180 and 181: XENIX Programming lex: Lexical Anal
<strong>XENIX</strong> Programming as: Assembler<br />
Assembly Segments<br />
as assembles instruction and data statements in three segments, text, data, and bss.<br />
Segments allow division of instructions and data into separate physical segments in<br />
memory. A location counter keeps the current address within each segment during<br />
assembly and provides reference to the current instruction and data.<br />
Text, Data, and Bss Segments<br />
Every program is divided into at most three distinct segments of assembled code and<br />
data: the text segment, the data segment, and the bss segment. Each segment is<br />
reserved for a specific type of storage and receives different treat ment from the<br />
assembler and from the <strong>XENIX</strong> linker when the final program is created.<br />
The text segment is normally reserved for instructions but may also be used for data.<br />
Instructions in this segment are assembled, and the code is copied to the output file.<br />
Data definitions in this segment are also assembled and copied; the code is the value of<br />
the data item. The assembler does not separate the instruction and data code. If the<br />
instructions and data definitions are mixed within the source file, the resulting code is<br />
mixed within the output file.<br />
The data segment is reserved for data. The code is copied to a different part of the<br />
output file and receives different treat ment from the <strong>XENIX</strong> linker.<br />
The bss segment is reserved for uninitialized data only. Instructions or data definitions<br />
with initial values must not be given in this segment. The assembler counts the nu mber<br />
of bytes allocated for this segment and copies this count to the output file. It does not<br />
generate code.<br />
The text segment is implicitly defined at the start of every assembly. Thus, any<br />
instructions or data definitions given when no other segment is explicitly defined are<br />
copied to the text segment. To start a data or bss segment, you must use a .data or .bss<br />
directive. You can explicitly start the text segment with the .text directive (see the<br />
section "Segment Directives," later in this chapter).<br />
Unless otherwise specified, the first statement in the text segment is considered the<br />
program's entry point. In shared-text programs, the instructions and data in the text<br />
segment are write-protected; in nonshared-text programs, they are not. Instructions<br />
and data in the data segment are never write-protected. The bss segment is actually an<br />
extension of the data segment. It begins immediately after the data segment and is<br />
initialized to 0 at the start of program execution.<br />
7-3