2/20/2013
Microprocessor and Interfacing II
ASSEMBLY LANGUAGE
PROGRAMMING
ASSEMBLY LANGUAGE
PROGRAMMING
Software: The Microcomputer Program.
Assembly Language Programming
Development on the PC.
The Instruction Set.
Addressing Mode.
1
2/20/2013
Software : The Microcomputer
Program.
The sequence of commands used to tell a
microcomputer what to do is called a program.
Each command in a program is an instruction.
The 8088 microprocessor performs operations for
117 basic instructions.
Programs must be coded in machine language
before they can be run by the 8088. However,
programs are normally written in 8088 assembly
language or a high-level language such as C.
A single machine language instruction can take
one to six bytes of code.
Software : The Microcomputer
Program
An instruction can be divided into two parts:
Operation code (opcode)- one-to five-letter
mnemonic
Destination Operand
Opcode
Operands
Source Operand
ADD AX, BX
Format of an assembly statement :
LABEL:INSTRUCTION ; COMMENT
e.g. START: MOV AX, BX; Copy BX into AX
2
2/20/2013
Software : The Microcomputer
Program
Assembly language must be converted by an
assembler to an equivalent machine language
program for execution by an 8088.
A directive is a statement that is used to control
the translation process of the assembler.
e.g. DB 64 DUP(?)
The machine language output produced by the
assembler is called object code.
Listing of the assembled program
e.g. 0013 8A 24 NXTPT: MOV AH , [SI] ; Move a byte
Software : The Microcomputer
Program
Assembly language versus high-level language.
It is easier to write program with high-level
language.
Program written in assembly language usually
takes up less memory space and executes much
faster.
Device service routines are usually written in
assembly language.
Assembly language is used to write those parts of
the application that must perform real-time
operations, and high-level language is used to
write those parts that are not time critical.
3
2/20/2013
Assembly Language Programming
Development on the PC
Program development cycle
4
2/20/2013
Assembly Language Programming
Development on the PC
The development programs and users files
The Instruction Set
The instruction set of a microprocessor
defines the basic operations that a
programmer can specify to the device to
perform.
Instruction set groups
Data transfer instructions
Arithmetic instructions
Logic instructions
String manipulation instructions
Control transfer instructions
Processor control instructions
5
2/20/2013
The Instruction Set
Data transfer instructions
The Instruction Set
Data transfer instructions
6
2/20/2013
The Instruction Set
Arithmetic instructions
The Instruction Set
Arithmetic instructions
7
2/20/2013
The Instruction Set
Logic instructions
The Instruction Set
String manipulation instructions
8
2/20/2013
The Instruction Set
Control transfer instructions
The Instruction Set
Control transfer instructions
9
2/20/2013
The Instruction Set
Control transfer instructions
The Instruction Set
Process control instructions
10
2/20/2013
The MOVE Instruction
The move (MOV) instruction is used to
transfer a byte or a word of data from a
source operand to a destination operand.
e.g. MOV DX , CS
MOV [SUM] , AX
The MOVE Instruction
Note that the MOV instruction cannot
transfer data directly between external
memory.
Allowed operands for MOV instruction
11
2/20/2013
The MOV Instruction
MOV DX, CS
The MOV Instruction
MOV DX, CS
12
2/20/2013
Addressing Modes
Register operand addressing mode
Immediate operand addressing mode
Memory operand addressing mode
Direct addressing mode
Register indirect addressing mode
Based addressing mode
indexed addressing mode
Based-indexed addressing mode
Addressing Modes
Register operand addressing mode
The operand to be accessed is specified as residing in
an internal register of 8088.
e.g. MOV AX, BX
13
2/20/2013
Addressing Modes
Register operand addressing mode
Addressing Modes
Register operand addressing mode
14
2/20/2013
Addressing Modes
Immediate operand addressing mode
Addressing Modes
Immediate operand addressing mode
15
2/20/2013
Addressing Modes
Memory addressing modes
To reference an operand in memory, the 8088
must calculate the physical address (PA) of the
operand and then initiate a read or write operation
to this storage location.
Addressing Modes
Memory addressing modes – Direct
addressing mode
e.g. MOV AX, [1234H]
16
2/20/2013
Addressing Modes
Memory addressing modes – Direct
addressing mode
Addressing Modes
Memory addressing modes – Direct
addressing mode
17
2/20/2013
Addressing Modes
Memory addressing modes – Register indirect
addressing mode
e.g. MOV AX, [SI]
Addressing Modes
Memory addressing modes – Register indirect addressing
mode
PA = 0200016+123416=0323416
18
2/20/2013
Addressing Modes
Memory addressing modes – Register indirect addressing mode
PA = 0200016+123416=0323416
Addressing Modes
Memory addressing modes – Based addressing mode
e.g. MOV [BX] + 1234H , AL
19
2/20/2013
Addressing Modes
Memory addressing modes – Based addressing mode
PA =0200016 + 100016 +123416 =0423416
Addressing Modes
Memory addressing modes – Based addressing mode
PA =0200016 + 100016 +123416 =0423416
20
2/20/2013
Addressing Modes
Memory addressing modes – Indexed addressing
mode
e.g. MOV AL , [SI] +1234H
Addressing Modes
Memory addressing modes – Indexed addressing
PA = 02000 +2000 +1234 = 05234
16 16 16 16
21
2/20/2013
Addressing Modes
Memory addressing modes – Indexed addressing mode
PA = 02000 +2000 +1234 = 05234
16 16 16 16
Addressing Modes
Memory addressing modes – Based-indexed addressing
mode
e.g. MOV AH, [BX][SI + 1234H]
22
2/20/2013
Addressing Modes
Memory addressing modes – Based-indexed addressing mode
PA = 02000 + 1000 + 2000 + 1234 = 06234
16 16 16 16 16
Addressing Modes
Memory addressing modes – Based-indexed addressing mode
PA = 02000 + 1000 + 2000 + 1234 = 06234
16 16 16 16 16
23