8086 Assembly Language Program to sort numbers in ascending/descending orders
8086 Assembly Language Program to sort numbers in ascending/descending orders
DATA SEGMENT
x DW 42H,34H,26H,17H,09H
LEN EQU 05
ASCD DB 10 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV BX,LEN-1
MOV CX,BX
UP1: MOV BX,CX
LEA SI,X
UP: MOV AX,[SI]
MOV DX,[SI+2]
CMP AX,DX
JB DOWN/JA DOWN
MOV [SI],DX
MOV [SI+2],AX
DOWN: INC SI
INC SI
DEC BX
JNZ UP
DEC CX
JNZ UP1
MOV AH,4CH
INT 21H
CODE ENDS
END START