Hardware Reference
In-Depth Information
This assembler uses three different sections, in which the translated code and
data will be stored. Those sections are related to the memory segments of the
machine. The first is the TEXT section , for the processor instructions. Next is the
DATA section for the initialization of the memory in the data segment, which is
known at the start of the process. The last is the BSS ( Block Started by Symbol ),
section, for the reservation of memory in the data segment that is not initialized
(i.e., initialized to 0). Each of these sections has its own location counter. The pur-
pose of having sections is to allow the assembler to generate some instructions,
then some data, then some instructions, then more data, and so on, and then have
the linker rearrange the pieces so that all the instructions are together in the text
segment and all the data words are together in the data segment. Each line of
assembly code produces output for only one section, but code lines and data lines
can be interleaved. At run time, the TEXT section is stored in the text segment and
the data and BSS sections are stored (consecutively) in the data segment.
An instruction or data word in the assembly language program can begin with
a label. A label may also appear all by itself on a line, in which case it is as though
it appeared on the next instruction or data word. For example, in
CMP AX,ABC
JE L
MOV AX,XYZ
L:
L is a label that refers to the instruction of data word following it. Two kinds of
labels are allowed. First are the global labels , which are alphanumeric identifiers
followed by a colon (:). These must all be unique, and cannot match any keyword
or instruction mnemonic. Second, in the TEXT section only, we can have local
labels , each of which consists of a single digit followed by a colon (:). A local
label may occur multiple times. When a program contains an instruction such as
JE 2f
this means JUMP EQUAL forward to the next local label 2 . Similarly,
JNE 4b
means JUMP NOT EQUAL backward to the closest label 4 .
The assembler allows constants to be given a symbolic name using the syntax
identifier = expression
in which the identifier is an alphanumeric string, as in
BLOCKSIZE = 1024
Like all identifiers in this assembly language, only the first eight characters are sig-
nificant, so BLOCKSIZE and BLOCKSIZZ are the same symbol, namely, BLOCK-
SIZ .
Expressions
can
be
constructed
from
constants,
numerical
values,
and
 
Search WWH ::




Custom Search