Chapter 4 - Requirements For Coding in Assembly Language
Chapter 4 - Requirements For Coding in Assembly Language
Chapter Outline
Assembly Language Features
Simplified segment Directive
Defining Types of data
Equate Directive
Program Comment
The comment field of a statement is used by the programmer to say
something about what the statement does.
A semicolon marks the beginning of this field, and the assembler
ignores anything typed after the semicolon.
It is almost impossible to understand an assembly language program
without comments.
Good programming practice dictates a comment on almost every
line.
13
Program Comment
Examples:
MOV CX, 0
Thus, comments is used to put the instruction into the context of the
program.
It is permissible to make an entire line a comment, and to use them
to create space in a program.
14
Reserved words
Instructions, such as MOV and ADD
Directives, such as END that used to provide
information to the assembler
Operators
Predefined symbols, such as @Data, which return
information to your program during the assembly
Identifiers
Two types of Identifiers : name and label
1. Name refers to the address of a data items
ex: COUNTER ,SUM,ID
2. Label refers to the address of an
instruction,procedure,or segment
ex: MAIN
Identifiers
Can be from 1 to 31 characters long (not case sensitive).
May consist of letters, digits, and the special characters
? . @ _ $ % (Thus, embedded blanks are not allowed).
Names may not begin with a digit.
If a dot is used, it must be the first character.
Identifiers
Examples:
COUNTER1
2abc
@CHARACTER
A45. 28
TWO WORDS
STD_NUM
.TEST
YOU&ME
Statements
Both instructions and directives have up to four fields:
[identifier ] operation
[operand(s)] [comment]
[Name Fields are optional]
At least one blank or tab character must separate the fields.
The fields do not have to be aligned in a particular column, but they
must appear in the above order.
An example of an instruction:
START:
MOV CX,5 ; initialize counter
An example of an assembler directive:
MAIN
PROC
6
Directives
SEGMENT Directive
Data Segment
Stack segment
Code Segment
END Directive
ex: ENDP directive ends a procedure
ex: END directive ends the entire program and appears as the last
statment
memory_model
Model
SMALL
MEDIUM
COMPACT
LARGE
HUGE
Description
code in 1 segment
data in 1 segment
code > 1 segment
data in 1 segment
code in 1 segment
data > 1 segment
code > 1 segment
data > 1 segment
no array larger than 64k bytes
code > 1 segment
data > 1 segment
arrays may be larger than 64k bytes
size
DW 2
DB this is a message