8086ALP
8086ALP
CMPSB/CMPSW
Used to compare two strings of bytes or words.
Length of the byte/ word string in CX.
If both bytes/ words are equal, ZF is set.
Strings are stored in DS:SI & ES:DI
REP is used to repeat the comparison operation till CX=0 or
condition specified by REP fails.
CMPSB/CMPSW - Example
1
26-03-2024
2
26-03-2024
3
26-03-2024
4
26-03-2024
5
26-03-2024
6
26-03-2024
7
26-03-2024
AD0-AD15 (Bidirectional)
• Low order address bus; these are
multiplexed with data.
• When AD lines are used to transmit
memory address the symbol A is used
instead of AD, for example A0-A15.
• When data are transmitted over AD
lines the symbol D is used in place of
AD, for example D0-D7, D8-D15 or D0-
D15.
8
26-03-2024
9
26-03-2024
10
26-03-2024
𝑴𝑵/𝑴𝑿
• The 8086 microprocessor can work in two modes of operations:
Minimum mode and
Maximum mode.
• In the minimum mode of operation the microprocessor do not
associate with any co-processors and cannot be used for
multiprocessor systems.
• In the maximum mode the 8086 can work in multi-processor or
co-processor configuration.
• Minimum or maximum mode operations are decided by the pin
MN/ MX(Active low).
• When this pin is high 8086 operates in minimum mode otherwise
it operates in Maximum mode.
11
26-03-2024
𝐃𝐄𝐍 (Data Enable) indicates the availability of valid data over the
address/ data lines. It is used to enable the transceivers to
separate the data from the muliplexed address/data signal. It is
active from the middle of T2 until the middle of T4.
M/𝐈𝐎 Used to differentiate memory access and I/O access. For memory
reference instructions, it is high. For IN and OUT instructions, it is
low.
106
107
12
26-03-2024
108
109
13
26-03-2024
14
26-03-2024
15
26-03-2024
16
26-03-2024
17
26-03-2024
18
26-03-2024
19
26-03-2024
20
26-03-2024
21
26-03-2024
Algorithm:
1. Initialize the data segment.
2. Initialize the number of elements counter.
3. Initialize the pointer and number of comparisons
counter.
4. Compare the elements. If first element < second
element go to step VI else go to step V.
5. Swap the elements.
6. Increment the pointer. Decrement the
comparison counter.
7. Is count = 0? If yes, go to step VIII else go to
step IV.
Algorithm:
8. Decrement the number of elements counter.
9. Is count = 0? If yes, go to step X else go to step
III.
10.Stop.
22
26-03-2024
23
26-03-2024
INT 21H
END START
DEC CL
INC SI
L1 : CMP AL,[SI]
24
26-03-2024
Sorting of Numbers JC L3
DEC CL INC SI
DEC CH DEC CL
INC SI JNZ L1
INC SI
CMP AL, [SI]
25