Organization of The IBM PC Assembly Language
Organization of The IBM PC Assembly Language
Assembly Language
Lecture#08
Assembly Language Syntax
Assembly Language programs are translated
into machine language instruction by an
assembler, so they must be written to confirm
to assembler’s specifications.
Statements
Programs consist of statements, one per line. Each
statement is either an instruction, which the
assembler translates into machine code, or an
assembler directives which instructs the assembler
to perform some specific tasks. Both instructions
& directives have up to four fields.
Example
COUNTER1
@character
SUM_OF_DIGITS
$1000
Operation Field
Example:
MOV ADD SUB
Operand Field
For an instruction the operand field specifies the data
that are to be acted on by the operation. An
instruction may have zero, one or two operands.
For Example:
NOP no operand; does nothing
INC AX 1 operand; adds 1 to the
contents of AX
ADD WORD1, 2 2 operands; add 2 to the
contents of memory word
WORD1
Comment Field
A comment field of a statement is used by the
programmer to say something about what the
statement does. A semicolon marks the
beginning of the field, & the assembler ignores
anything typed after the semicolon.
For Example:
MOV CX, 0 ;CX counts terms, initially 0.
Assembly Program Structure
The most important parts of an assembly
language program are memory models, data
segment, stack segment & code segment.
Memory Models
The size of code & data program can have is
determined by specifying a memory model using
the .MODEL directive. The syntax is
.MODEL memory_model
Data Segment
A program’s data segment contains all the variable
definitions. To declare a data segment, we use the
directive .DATA, followed by variable & constant
declarations.
For Example:
.DATA
MSG DB ‘This is an message’
WORD1DW 2
WORD2DW 5
Stack Segment
The purpose of the stack segment declaration is to
set aside a block of memory to store the stack. The
syntax is
.STACK size
.STACK 100H
Code Segment
The code segment contains a program’s
instructions. The syntax is
.CODE name
For Example:
.CODE
MAIN PROC ; main procedure instructions
MAIN ENDP ; other procedure go here