Code:
; Program to arrange number in ascending order
.MODEL SMALL
.STACK 100H
.DATA
ARR DB 2H,5H,0H,7H,3H
.CODE
MOV AX , @DATA ;Initializing data segment
MOV DS , AX
MOV BX , 5 ;Set pass counter
NEXTPASS:
MOV CX , 4
MOV SI , OFFSET ARR ; initializing array base address
NEXT:
MOV AL , [SI] ; STORING NUMBER
CMP AL , [SI+1] ; COMPARING 1ST AND 2ND NUMBER
JC UP
XCHG AL , [SI+1]
XCHG AL , [SI]
UP:
INC SI ; INCREMENT ARRAY INDEX
LOOP NEXT
DEC BX ; DECREMENT PASS COUNTER
JNZ NEXTPASS ; JUMP IF NOT ZERO
MOV AH , 4CH ; SERVICE ROUTINE FOR EXIT
INT 21H
END
; Program to arrange number in ascending order
.MODEL SMALL
.STACK 100H
.DATA
ARR DB 2H,5H,0H,7H,3H
.CODE
MOV AX , @DATA ;Initializing data segment
MOV DS , AX
MOV BX , 5 ;Set pass counter
NEXTPASS:
MOV CX , 4
MOV SI , OFFSET ARR ; initializing array base address
NEXT:
MOV AL , [SI] ; STORING NUMBER
CMP AL , [SI+1] ; COMPARING 1ST AND 2ND NUMBER
JC UP
XCHG AL , [SI+1]
XCHG AL , [SI]
UP:
INC SI ; INCREMENT ARRAY INDEX
LOOP NEXT
DEC BX ; DECREMENT PASS COUNTER
JNZ NEXTPASS ; JUMP IF NOT ZERO
MOV AH , 4CH ; SERVICE ROUTINE FOR EXIT
INT 21H
END