You are on page 1of 20

Chapter 3

Elements of Assembly language


Name
(Label)
START : MOV AL,X ; Take the first number
ADD AL,Y ; Adding the second number
MOV [2400H],AL ; Storage of calculation results
X DB 12H ; Definition of numbers
Y DB 24H
Name Statements Comment
(Label)
Instruction

Directive
Instruction format
Name/label mnemonic operand(s) ;comment
Must be required
Not must be required
MOV
START : MOV MOV AL,X
START ADDAL,X
AL,X : MOV ; Take the first number
X DB 12H ADD AL,Y
START : MOV AL,X ; Take the first number
MOV [2400H],AL
Spaces are required
Either uppercase or lowercase letters is ok.
PUSH AX
DATA SEGMENT
X DB 12H ; Definition of numbers
Y DB 24H DATA SEGMENT
Z DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN: MOV AX,DATA CODE SEGMENT
MOV DS,AX
MOV AL,X ; Take the first number
ADD AL,Y ; Adding the second number
MOV Z,AL ; Storage of calculation results
STOP: JMP STOP
CODE ENDS
END MAIN
Editing the source
file
Typing the source
file
Assembling(Compilating)
the source file

The source file


Linking the object
file

The object file


Debugging the run
file
Demonstration
3.4 Constant operands
Numeric operands can be expressed in decimal,hexdecimal
and binary.

Suffix
Binary numer 00100110B

Suffix
Hexdecimal numer 26H

None
Decimal numer 38
Constants are written the same way
in directives and in instructions.

MOV AL, 00100110B


MOV AL,26H Instructions
MOV AL,38

X DB 00100110B
X DB 26H Directives
X DB 38
3.5 Instruction operands

There are three basic types of instruction operands.

Constants MOV AL,34H

CPU registers MOV AL,BL

Memory locations MOV AL,[2400H]


Modes for Providing operands
There are four basic types of Modes for Providing
operands.
Mode Location of data
Immediate In the instruction itself
MOV AL,34H
Register In a register
MOV AL,BL
Direct At a memory location whose address
is built into the instruction
MOV AL,[2400H]
Register indirect At a memory location whose address
is in a register
MOV AL,[BX]

You might also like