You are on page 1of 34

INTRODUCTION

TO THE
INSTRUCTION SET OF
8088 MICROPROCESSOR

1 PNEC
Instruction Set of 8088 MP
 8086/8088 M.Ps Instruction Set
 Divided into following Categories;
i) Data Movement Instructions
ii) Arithmetic & Logic Instructions
iii) Shift & Rotate Instructions
iv) Program Transfer Instructions
v) String Instructions

2 PNEC
Instruction Set of 8088 MP

i) Data Movement Instructions

Examples:

MOV, IN, OUT, PUSH, POP,

XCHG Instructions

3 PNEC
Instruction Set of 8088 MP

ii) Arithmetic & Logic Instructions

Examples:

Arithmetic Instructions: ADD, SUB, MUL, DIV etc

Logic Instructions: AND, OR, XOR, NOT etc

4 PNEC
Instruction Set of 8088 MP

 Shift & Rotate Instructions

Examples:

Shift Instructions: SHL, SHR

Rotate Instructions: ROL, ROR etc

5 PNEC
Instruction Set of 8088 MP

Program Transfer Instructions:

Examples:

Call & Return, Jump Instructions

6 PNEC
Instruction Set of 8088 MP

 String Instructions:

Examples:

MOVS, SCAS, CMPS etc

7 PNEC
Instruction Set of 8088 MP
Description of some Data Movement Commands: MOV Command

i) In MOV command syntax is Move Destination, Source


Example: MOV AH,BL
Here ‘Source’ of data is BL register and ‘Destination’ of data is AH
register.
On execution of this command data in BL ‘moves’ into AH register.
[Note: In actual data is not moved rather copied and pasted in AH]
In this command Source and Destination can be registers,
memory locations(but not two locations in same command) and
some number can also be used as source, but not as destination.

8 PNEC
Instruction Set of 8088 MP
Description of some Data Movement Commands: OUT Command
i) In OUT command syntax is OUT Destination, Source
Example: OUT DX,AL
Here ‘Source’ of data is AL register and ‘Destination’ of data is
mentioned, in form of Address, in DX register.
On execution of this command data in AL ‘moves’ to the O/P
device whose address is present in DX register.
[Note: Data in AL is not moved into DX, rather copied and sent to
the output device whose address is mentioned in DX]
Remember in o/p operation Data must be kept in AL register and
Address of the device in DX register.

9 PNEC
Instruction Set of 8088 MP
Description of some Arithmetic Commands:
MUL Commands
i) In Multiply command for ‘Byte times Byte operation’ or simply ‘8 bit
Multiplication’, Multiplicand is to be kept in AL register and
multiplier in other 8 bit register or a memory location
Example: MUL BL; AL x BL=16 bit result goes in AX register
ii) For ‘Word times Word operation’ or simply 16 bit multiplication,
Multiplicand is kept in AX register and multiplier in other 16 bit
register or a memory locations
& 32 bit result goes in AX & DX register, with Higher 16 bits in DX &
lower 16 bits in AX Registers respectively
Example: MUL BX; AX x BX= 32 bit result goes in DX & AX
10 PNEC
Instruction Set of 8088 MP
Description
DIV commands:
In 8 bit division, Dividend is kept in AX register divider in other 8
bit register or a memory location. After division Quotient goes in
AL & Remainder goes in AH
Example: DIV BL; AX / BL => Quotient = AL, Remainder = AH

In 16 bit division, Dividend is kept in DX-AX registers, after


division Quotient goes in AX & Remainder goes in DX
Example: DIV CX; DX & AX / CX => Qtnt = AX, Rmdr = DX

11 PNEC
Instruction Set of 8088 MP
Description
Logic Commands Examples:
AND AX, BX
OR CX, DX
NOT BH
XOR BL, DH
If AX = FFFFh, BX = 00AAh, i.e AX = 1111 1111 1111 1111
& BX = 0000 0000 1010 1010
and we run the command AND AX,BX, then after execution
=> AX = 0000 0000 1010 1010h & BX remains unchanged

12 PNEC
Instruction Set of 8088 MP
Logic Commands
Examples:
If AX = FFFFh, BX = 00AAh, i.e
AX = 1111 1111 1111 1111
BX = 0000 0000 1010 1010
XOR AH, BL
AH = 1111 1111
BL = 1010 1010
Þ AH = 0101 0101
Þ BL = 10101010 (unchanged)

13 PNEC
Instruction Set of 8088 MP

Logic Commands
Example:
BH = 0000 1111
NOT BH
=> BH = 11110000

14 PNEC
Instruction Set of 8088 MP

Shift Command
If CH = 00000001
SHL CH, 01
=> CH = 00000010
AL = 10000000
SHR AL,01
=> AL = 01000000

15 PNEC
Instruction Set of 8088 MP

Logic Commands
Examples:
 Rotate Command
 CH = 00000001
 ROR CH, 01
 => CH = 10000000
 AL = 10000000
 ROL AL,01
 => AL = 00000001

16 PNEC
Instruction Set of 8088 MP

Some more Arithmetic Instructions


INC & DEC
INC: Increment ; It increments the contents of a register
by 1
DEC: Decrement ; It decrements the contents of a
register by 1
Examples: INC CX; Increment the contents of CX by 1,
so if earlier CX = 0025h now CX = 0026h
And if DEC CX now CX = 0024h

17 PNEC
Instruction Set of 8088 MP

Program Transfer Instructions:


CALL & RET Commands
This is a pair of commands. These commands are
used for a ‘Subroutine’. When in a program, user
needs to access or execute a subroutine, CALL
command is used.
And RET command is written as the last command
of a subroutine to return or go back to the main
program

18 PNEC
Instruction Set of 8088 MP

 Program Transfer Instructions:


 JUMP Commands;
 These commands are divided into two broad
categories;
i) Conditional Jump commands &
ii) Un Conditional Jump commands

19 PNEC
Instruction Set of 8088 MP
 Program Transfer Instructions:
 Un Conditional JUMP Commands;
 Example: JMP 0100h
 In this command MP is asked to jump to the
mentioned memory location (eg address 0100h),
while doing this no condition is required to be
satisfied or tested. It is just an order for MP to ‘jump’
i.e to a particular memory location and fetch the next
instruction from it.

20 PNEC
Instruction Set of 8088 MP
 Types of Unconditional jump commands;
i) Short Jump, ii) Near Jump and iii) Far Jump
Range of each type is +/- 128 Bytes, +/- 32KB, 64KB
respectively, from the location on which the jump command is
written
Short Jump is of 2 Bytes, one byte for the opcode and other for the
address,
Near jump is of 3 bytes, one for the opcode and two bytes for the
address,
Far jump is of 5 bytes, one for the opcode and four bytes for the
address

21 PNEC
Instruction Set of 8088 MP
 Conditional JUMP Commands;
 Examples: JS, JZ, JNZ, JP, JNP, JG, JL etc
 In these commands MP is asked to jump to the
mentioned memory location (eg address 0100h),
while doing this, specified condition/status is required
to be satisfied. It is just an order for MP to ‘jump’ to a
particular memory location and fetch the next
instruction from it, if and only if condition is satisfied,
otherwise not.

22 PNEC
Instruction Set of 8088 MP
 Conditional JUMP Commands;
 Conditional Jump commands test the Flag bits of the Status/Flag
Register, like ZF, SF, OF, PF, CF etc,
 If the condition under test is found to be true, only then jump
takes place.
 Range of Conditional Jumps is +127 bytes ahead and -128 bytes
back from the location on which the jump command is written
 Example: SUB AL,BL
JZ Address
 In the above example if due to the Subtraction Zero Flag gets
Set, now when JZ command tests the ZF and finds it Set then
MP “jumps” to the specified address/location and fetches the
23 next command from it PNEC
Instruction Set of 8088 MP
 Conditional JUMP Commands;
 Example 1: SUB AL,BL
JZ Address
 In the above example if due to Subtraction, Zero Flag gets Set,
now when JZ command tests the ZF and finds it Set then MP
“jumps” to the specified address/location and fetches the next
command from it
 Example 2: ADD AH,DH
JC Address
In the above example if due to Addition, Carry Flag gets Set, now
when JC command tests the CF and finds it Set then MP “jumps”
to the specified address/location and fetches the next command
24 from it PNEC
Instruction Set of 8088 MP (Contd)
 Conditional JUMP Commands: More Examples;
 JL = Jump if Less
 JG = Jump if Greater
 JA = Jump if Above
 JB = Jump if Below
 JE = Jump if Equal
 JAE = Jump if Above or Equal
 JLE = Jump if Less or Equal

25 PNEC
Instruction Set of 8088 MP
 String Instructions:
 By ‘String’ we mean series of data on consecutive
memory locations
 String commands are power full command which
allow the programmer to perform operations on large
blocks of data, present on consecutive locations.
Operations may include movement of data, scanning
of data, comparison of data etc.
 Examples: MOVS, SCAS, CPMS etc

26 PNEC
the MOVS instruction is used to copy a
data item (byte, word or doubleword) from
the source string to the destination string.
The source string is pointed by DS:SI and
the destination string is pointed by ES:DI.

The SCAS instruction is used for searching


a particular character or set of characters in
a string. The data item to be searched
should be in AL (for SCASB), AX (for
SCASW) or EAX (for SCASD) registers.
The string to be searched should be in
memory and pointed by the ES:DI (or EDI)
register The CMPS instruction compares two strings.
This instruction compares two data items of one
byte, word or doubleword, pointed to by the
DS:SI and ES:DI registers and sets the flags
accordingly. You can also use the conditional
jump instructions along with this instruction.
The following example demonstrates comparing
two strings using the CMPS instruction −
27 PNEC
Instruction Set of 8088 MP

String Instruction ‘MOVS’:


In the following set of commands, a block of
data is moved from DS to ES
Examples:
CLD
MOV DI, 2500
MOV SI, 3500
MOV CX, 0100
REP MOVSB
28 PNEC
Instruction Set of 8088 MP
 String Instruction ‘SCAS’ :It compares a String Byte with a byte
in AL or a String Word with a word in AX
 The String to be scanned must be in Extra Segment.
 Example: Suppose a section of 100 bytes of ES is to be
scanned for a specific data 50h;
STD
MOV DI, 3000
MOV AL, 50
MOV CX, 0100
REPNE SCASB

29 PNEC
Program Example 1
 Task:
Write a program to turn ON LEDs and a speaker, connected with
an I.C. Keep program running.

M.Ps data lines are connected to the I.C.


(This program is an example of Output Operation).

30 PNEC
31 PNEC
32 PNEC
Program Example 2
 Task:
Write a program to get data from an input device (having address
FF10h) and multiply it with a number 0Fh.
If the product is not greater than the number stored on memory
location 2000h then send it to the output device(having address
AA20h) and keep program running, other wise save it on memory
location 3000h and halt the program.
This program is an example of IN/OUT, Memory Read/Write and
Arithmetic operations.

33 PNEC
Program Example
Write comments for each command

MOV DX,FF10 ; Loading the address of the I/P device


IN AL,DX ; Taking the data from the I/P device into the AL
MOV BH,0F ; Loading the given no. in a register
MUL BH ; Multiplying the data in AL with the given no = 0Fh.
MOV BL,[2000h] ; Getting data from memory location into BL rgstr
CMP AL,BL [2000]; Comparing the product (assuming 8 bit product)
; with the data on memory location
JLE 1234 ; Jumping to the given address if the data is less/eq
MOV [3000],AL ; Saving the product (which is greater than the no.
; on memory location 2000, on memory loc 3000).
HLTJMP 0000 ; Jump to the start/continue Stop the program
1234: MOV DX,AA20h ; Loading the address of the O/P device
OUT DX,AL ; Sending the data (which is not greater) out to the
34 ; o/p device JMP 0000 ; Jump to
start to keep the program running

You might also like