.MODEL SMALL
.STACK 100
.DATA
prompt1 DB 10,15,'ENTER ANY WORDS : $'
prompt2 DB 10,15,'LENGTH OF THE WORDS IS : $'
prompt3 DB 10,15,'REVERSE OF YOUR ENTERED WORDS IS : $'
PROMPT DB "Do you want to continue using(y/n)?$"
ERROR DB "Please enter y or n only.$"
INPUT DB ?
NEWLINE DB 0AH,0DH,"$"
EXIT DB 'Thankyou for using ! Please come back next time!'
P LABEL BYTE
M1 DB 0FFH
L1 DB ?
P3 DB 0FFH DUP ('$')
P4 DB 0FFH DUP ('$')
DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
DISPLAY prompt1
LEA DX,P
MOV AH,0AH
INT 21H
DISPLAY prompt2
MOV DL,L1
ADD DL,30H
MOV AH,2
INT 21H
DISPLAY prompt3
LEA SI,P3
LEA DI,P4
MOV DL,L1
DEC DL
MOV DH,0
ADD SI,DX
MOV CL,L1
MOV CH,0
;----- Reverse the strings
REVERSE:
MOV AL,[SI]
MOV [DI],AL
INC DI
DEC SI
LOOP REVERSE
DISPLAY P4
LEA SI,P3
LEA DI,P4
MOV CL,L1
MOV CH,0
MOV AH,4CH
INT 21H
REPEAT:
MOV AH,09H
LEA DX,NEWLINE
INT 21H
MOV AH,09H
LEA DX,PROMPT
INT 21H
;-------------GET USER INPUT
MOV AH,01H
INT 21H
MOV INPUT,AL
CMP AL,"y"
JZ DISPLAY1
CMP AL,"n"
JE TERMINATE
JNE ERRORMSG
DISPLAY1:
MOV AH,09H
LEA DX,NEWLINE
INT 21H
ADD prompt1,1
MOV AH,02H
MOV DL,prompt1
INT 21H
JMP REPEAT
ERRORMSG:
MOV AH,09H
LEA DX,ERROR
INT 21H
JMP REPEAT
TERMINATE:
MOV AH,4CH
LEA DX,EXIT
INT 21H
MAIN ENDP
END MAIN