; Write a program to reverse a string.
.MODEL SMALL
.STACK 100H
.DATA
INPUT_MSG DB 'ENTER A STRING: $'
OUTPUT_MSG DB 0AH,0DH,'OUTPUT IS: $'
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
MOV AH, 9
LEA DX, INPUT_MSG
INT 21H
MOV AH,1
MOV CX, 0 ;CX is 0
TOP:
INT 21H
CMP AL,0DH ; the comparison with carriage return done to find the end of a string
JE END_INPUT
PUSH AX
INC CX
JMP TOP
END_INPUT:
MOV AH,9
LEA DX,OUTPUT_MSG
INT 21H
MOV AH, 2
OUTPUT:
POP DX
INT 21H
LOOP OUTPUT
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
.MODEL SMALL
.STACK 100H
.DATA
INPUT_MSG DB 'ENTER A STRING: $'
OUTPUT_MSG DB 0AH,0DH,'OUTPUT IS: $'
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
MOV AH, 9
LEA DX, INPUT_MSG
INT 21H
MOV AH,1
MOV CX, 0 ;CX is 0
TOP:
INT 21H
CMP AL,0DH ; the comparison with carriage return done to find the end of a string
JE END_INPUT
PUSH AX
INC CX
JMP TOP
END_INPUT:
MOV AH,9
LEA DX,OUTPUT_MSG
INT 21H
MOV AH, 2
OUTPUT:
POP DX
INT 21H
LOOP OUTPUT
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
No comments:
Post a Comment