0% found this document useful (0 votes)
100 views

Assembler Source Statement Label Field

The document discusses assembly language and assemblers. It provides details on: 1) The primary functions of an assembler including translating mnemonic instructions to machine code and creating object files and listings. 2) The typical components of an assembly language source statement including optional label, required operation, optional operand, and optional comment fields. 3) Different types of assemblers including one-pass, two-pass, resident, macro, cross, and meta assemblers. 4) The four types of assembler constants: arithmetic, character, string, and symbolic constants.

Uploaded by

Amy Maskov
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Assembler Source Statement Label Field

The document discusses assembly language and assemblers. It provides details on: 1) The primary functions of an assembler including translating mnemonic instructions to machine code and creating object files and listings. 2) The typical components of an assembly language source statement including optional label, required operation, optional operand, and optional comment fields. 3) Different types of assemblers including one-pass, two-pass, resident, macro, cross, and meta assemblers. 4) The four types of assembler constants: arithmetic, character, string, and symbolic constants.

Uploaded by

Amy Maskov
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

The problem with assembly language is that it requires a high level of technical

knowledge, and it's slow to write. In the same time that you take to write ten
lines of assembly language- that's ten instructions, you could write ten lines of
C++, perhaps the equivalent of 500 instructions!

main()
{
int a = 1; int b = 2; int c;

__asm{
mov eax, a ;// Load the value of the a variable into the EAX register
mov ebx, b ;// Load the value of the b variable into the EBX register
add eax, ebx ;// Add EAX to EBX, and write the result into EAX
mov c, eax ;// Load the EAX value into the c variable
}
printf("a + b = %x + %x = %x\n",a,b,c);
}
An assembler is a translator that translates source instructions (in symbolic language) into target
instructions (in machine language), on a one to one basis.
The assembler performs the following primary functions:

1 Converts machine instructions, coded in mnemonic form, to their binary representation,


and writes that representation to a relocatable object file which is suitable for linking with
other object files to create an absolute load file.
2 Creates an assembler listing file, providing a mapping of the source code statements to
their
machine representation.
3 Allows frequently occurring source sequences to be coded as macros, which can be called
out using a single directive.
4 Provides high-level control structures for decision and loop control to support structured
assembly language programming.
5 Supports conditional assembly of portions of a source module.
6 Allows the source module to be split over multiple physical source files, which are
processed as a single entity through a file inclusion mechanism.
7 Performs syntax checking on the source statements, and notify the programmer of invalid
forms.
8 Provides debug information to the object module, to support assembler language
debugging at the source module level.

A typical source line has four fields. A label (or a location), a mnemonic (or operation), an operand,
and a comment. There are four fields in a source statement, listed here in the order in which
they must appear on a source statement:
1. Label Field 2. Operation Field 3. Operand Field 4. Comment Field
The general syntax for source statements is as follows:
[label [:] ] operation [operands] [; comment]

Assembler Source Statement Label Field


The label field is optional. If used, it contains a label to identify the source statement. A
labeled
statement may be referenced by another statement using the statement label. The label is
usually assigned the value of the assembler’s location counter. Any valid assembler symbol
may be placed in the label field; a label is simply an assembler symbol used in the label field.
Sometimes programmers interchange the usage of ‘label’ and ‘symbol’, but there is a subtle
difference.
A statement may contain only one label in the label field. If present, the label must be a
valid assembler symbol. Labels and symbols are case sensitive; uppercase is distinct from
lowercase.
If the label does not begin in column one, the label must be suffixed with a colon ( :). If the
label is specified in column one, the colon suffix is optional. Whitespace may separate the
label and the colon suffix.

Assembler Source Statement Operation Field


The operation field contains an operation code. This field contains the symbolic name
(mnemonic) for an assembler, machine or macro call directive. This field is required if the
operand field is used, and may be coded in any position after the label field. If the label field
is omitted, the operation field may begin in any position after column one, so long as nothing
other that whitespace precedes it. If the label field is specified, whitespace may optionally
separate the label from the operation code.

Assembler Source Statement Operand Field

The operand field of an assembly language statement supplies the arguments to the machine
instruction, assembler directive, or macro.

The operand field may contain one or more operands, depending on the requirements of the
preceding machine instruction or assembler directive. Some machine instructions and assembler
directives don't take any operand, and some take two or more. If the operand field contains more
than one operand, the operands are generally separated by commas, as shown here: operand
[ , operand ] ... ]

Comment Field
The comment field is optional; if used, it contains a comment. Comments are introduced with
the comment character ( ;). After the comment character, any string of ASCII text characters
may be coded (except newline, which delimits source statements). The comment character
may optionally be separated from a preceding field by coding whitespace characters. If there
are no preceding fields, the comment character may be specified in the first column, or it
may be preceded by whitespace.

Assembler Constants
The assembler constant is a self-defining term whose value is specified explicitly. The
assembler supports four kinds of constant:

1. Arithmetic Constants 2. Character Constants 3. String Constants 4. Symbolic Constants

Types of assembler
A One-pass Assembler: One that performs all its functions by reading the sourcefile once.
A Two-Pass Assembler: One that reads the source file twice.
A Resident Assembler: One that is permanently loaded in memory. Typically such an assembler
resides in ROM, is very simple (supports only a few directives and no macros), and is a one-pass
assembler.
A Macro-Assembler: One that supports macros
A Cross-Assembler: An assembler that runs on one computer and assembles programs for another.
Many cross-assemblers are written in a higher-level language to make them portable. They run on a
large machine and produce object code for a small machine.
A Meta-Assembler: One that can handle many different instruction sets.
A Disassembler: This, in a sense, is the opposite of an assembler. It translates machine code into a
source program in assembler language.
A one pass assembler passes over the source file exactly once, in the same pass collecting the labels,
resolving future references and doing the actual assembly. The difficult part is to resolve future label
references and assemble code in one pass.

You might also like