0% found this document useful (0 votes)
16 views3 pages

Experiment 3

This document describes a program that uses bubble sorting to arrange numbers in an array in ascending and descending order. The program uses general purpose registers, logical operators, and loop instructions to compare elements, exchange elements if out of order, and repeat the process until the list is fully sorted. It provides the assembly code to perform both ascending and descending sorts. It also includes pre-lab and post-lab questions about the instructions and concepts used.

Uploaded by

blacktee mo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Experiment 3

This document describes a program that uses bubble sorting to arrange numbers in an array in ascending and descending order. The program uses general purpose registers, logical operators, and loop instructions to compare elements, exchange elements if out of order, and repeat the process until the list is fully sorted. It provides the assembly code to perform both ascending and descending sorts. It also includes pre-lab and post-lab questions about the instructions and concepts used.

Uploaded by

blacktee mo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab 3

Ex.No.3.Program to demonstrate decision making and looping operation.

3.1 Introduction:
The purpose of this experiment is to learn about the general purpose registers,
instruction sets, addressing modes and logical operators of 8086 by sorting the sequence of
numbers from the array stored in a memory location into ascending and descending series.

3.2 Hardware Requirement:

The 8086 Microprocessor kit, Power Supply.

3.3 Program Logic:

To arrange the given numbers in ascending and descending order, the bubble sorting method
is used. Initially the first number of the series is compared with the second one. If the first
number is greater than second, exchange their positions in the series otherwise leave the
position unchanged. Then compare the second number in the recent form of the series with
third and repeat the exchange part that you are carried out for the first and second number,
and for all the remaining number of the series. Repeat this procedure for complete series (n-
1) times. After n-1 iterations you will get the largest number at the end of the series. Again,
start from the first number of the series. Repeat the same procedure right from the first
element to the last element. After n-2 iteration you will get the second highest number at the
last but one place in the series. Repeat this till the complete series is arranged in ascending
order.

3.4 Program:
Introduction of general-purpose registers, logical operators, indirect addressing, and
loop instructions, compare instruction, exchange instruction, increment & decrement
instruction:
Ascending order:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
1000 MOV SI, 1200H TRANSFER DATA 1200HT
C7C60012 TO SI REGISTER
1004 MOV CL, [SI] 8A0C TRANSFER DATA FROM
SI TO CL
1006 DEC CL FEC9 DECREMENT CL
1008 LOOP3 MOV SI, 1200H C7C60012 DATA TRANSFER FROM
1200H TO SI
100C MOV CH, [SI] 8A2C DATA TRANSFER
FROM[SI] TO CH
100E DEC CH FECD DECREMENT CH
1010 INC SI 46 INCREMENT SI
1011 LOOP2 MOV AL, [SI] 8A04 DATA TRANSFER FROM
[SI] TO AL
1013 INC SI 46 INCREMENT SI
1014 CMP AL, [SI] 3A04 COMPARE DATA IN [SI]
AND AL
1016 JC LOOP1 7205 JUMP TO 1010
1018 XCHG AL, [SI] 8604 EXCHANGE DATAT FROM
SI
101A XCHG [SI-1], AL 8644FF EXCHANGE DATA
101D LOOP1 DEC CH FEC0 DECREMENT CH
101F JNZ LOOP2 75F0 JUMP T0 100^2
1021 DEC CL FEC9 DECREMENT CL
1023 JNZ LOOP3 75E3 JUMP TO 1008
1025 HLT F4 TERMINATE THE
PROGRAM

Descending order:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
1000 MOV SI, 1200H TRANSFER DATA 1200H
C7C60012 TO SI REGISTER
1004 MOV CL, [SI] 8A0C TRANSFER DATA
FROM SI TO CL
1006 DEC CL FEC9 DECREMENT CL
1008 LOOP3 MOV SI,1200H C7C60012 DATA TRANSFER
FROM 1200H TO SI
100C MOV CH, [SI] FA2C DATA TRANSFER
FROM[SI] TO CH
100E DEC CH FECD DECREMENT CH
1010 INC SI 46 INCREMENT SI
1011 LOOP2 MOV AL, [SI] 8A04 DATA TRANSFER
FROM [SI] TO AL
1013 INC SI 46 INCREMENT SI
1014 CMP AL, [SI] 3A04 COMPARE DATA IN
[SI] AND AL
1016 JNC 7305 7305 JUMP TO 1010
1018 XCHG AL, [SI] 8604 EXCHANGE DATAT
FROM SI
101A XCHG [SI-1], AL 8644FF EXCHANGE DATA
101D LOOP1 DEC CH FEC0 DECREMENT CH
101F JNZ LOOP2 75F6 JUMP T0 1010
1021 DEC CL FEC9 DECREMENT CL
1023 JNZ LOOP3 7563 JUMP TO 1008
1025 HLT F4 TERMINATE THE
PROGRAM
3.5 Pre-Lab Questions:

1. What are the flags modified while executing XCHG instruction?


2. List the addressing modes used in this program.
3. What is the purpose of AAA instruction?
4. List the type of jump instruction that are used in this program.

3.6 Post-Lab Questions:

1. Write an ALP to sort the given array of 16-bit numbers in ascending and descending
order using 8086 microprocessor.
2. Simulate the programs using emulator 8086.

Result:

You might also like