.MODEL SMALL
.DATA
NL1 DB 0AH,0DH,'IT IS ASCENDING ORDER$'
NL2 DB 0AH,0DH,'IT IS DESCENDING ORDER$'
FA DB 00
FD DB 00
STR1 DB 20 DUP(' '),'$'
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
LEA SI,STR1
MOV AH,01H
MOV CL,00H
LBL1:
INT 21H
CMP AL,0DH
JE LBL2
MOV [SI],AL
INC SI
INC CL
JMP LBL1
LBL2:
; DEC CL
MOV AL,'$'
MOV [SI],AL
LEA SI,STR1
MOV BL,CL
LBL4:
MOV AL,[SI]
CMP AL,[SI+1]
JL LBL6
INC SI
LOOP LBL4
LBL5:
CMP FA,00
JG LBL7
DES:
LEA DX,NL2
MOV AH,09H
INT 21H
JMP EXIT
LBL6:
INC FA
DEC CL
INC SI
JMP LBL4
LBL7:
DEC BL
CMP FA,BL
JNE DES
LEA DX,NL1
MOV AH,09H
INT 21H
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
;LBL2:
; MOV AL,'$'
; MOV [SI],AL
OUTPUT
***********
Z:\assembly\SYSTEM~1\AS1>EX9
ABC
IT IS ASCENDING ORDER
Z:\assembly\SYSTEM~1\AS1>EX9
DCA
IT IS DESCENDING ORDER