Write and execute an alp to 8086 Microprocessor to a sort the give array of 32 bit number in ascending and descending order.

1.Ascending order

Aim:

To write an assembly language program to arrange the given numbers in ascending   order.

Tools:

PC installed with TASM.

Program:

ASSUME CS : CODE, DS : DATA
CODE SEGMENT
MOV AX, DATA
MOV DS, AX
MOV DX, COUNT - 1
BACK : MOV CX, DX
MOV SI,OFFSET LIST
AGAIN : MOV AX, [SI]
CMP AX, [SI + 2]
JC GO
XCHG AX, [SI + 2]
XCHG AX, [SI]
GO:INC SI
INC SI
LOOP AGAIN
DEC DX
JNZ BACK
HLT
CODE ENDS
DATA SEGMENT
LIST DW 05H, 04H, 01H, 03H, 02H
COUNT EQU 05H
DATA ENDS
END

Flow Chart

Result:

Input:

LIST (DS : 0000H) = 05H, 04H, 01H, 03H, 02H

Output:

LIST (DS : 0000H) = 01H, 02H, 03H, 04H, 05H

 

2. Descending order

Aim:

To write an assembly language program to arrange the given numbers in descending order.

Tools:

PC installed with TASM.

Program:

ASSUME CS : CODE, DS : DATA
CODE SEGMENT
MOV AX, DATA
MOV DS, AX
MOV DX, COUNT - 1
BACK : MOV CX, DX
MOV SI, OFFSET LIST
AGAIN : MOV AX, [SI]
CMP AX, [SI + 2]
JNC GO
XCHG AX, [SI + 2]
XCHG AX, [SI]
GO:INC SI
INC SI
LOOP AGAIN
DEC DX
JNZ BACK
HLT
CODE ENDS
DATA SEGMENT
LIST DW 03H, 04H, 01H, 05H, 02H
COUNT EQU 05H
DATA ENDS
END

Flow Chart:

Result:

Input:

LIST (DS : 0000H) = 03H, 04H, 01H, 05H, 02H

Output:

LIST (DS : 0000H) = 05H, 04H, 03H, 02H, 01H

Viva-voce questions:

1. What is the word length of 8086 µP?
2. Which signal is used to separate address and data bus?
3. How many multiplexed lines are there in 8086 µP?
4. What is the maximum memory addressing and I/O addressing capability of 8086? 
5. What are the equivalent instructions to JZ and JNZ?