Code:
; Program to reverse the given String
.MODEL SMALL
.STACK 100H
.DATA
OSTR DB 'CODING$'
DSTR DB ?
LEN DB 0
.CODE
MOV AX , @DATA ; Initializing Data Segment
MOV DS , AX
; Printing the Orignal String
MOV AH , 09H
LEA DX , OSTR
INT 21H
; Printing New Line
MOV AH , 02
MOV DL , 13
INT 21H
MOV DL , 10
INT 21H
; Counting length of Orignal String
MOV SI , OFFSET OSTR
UP1:
MOV AL , [SI]
CMP AL , '$'
JE DN1
INC LEN
INC SI
JMP UP1
DN1:
; Reversing the string
MOV CL , LEN
MOV DI , OFFSET DSTR
UP2:
DEC SI
MOV AL , [SI]
MOV [DI] , AL
INC DI
LOOP UP2
MOV [DI] , '$' ; Storing the end of String
; Printing the Reverse String
MOV AH , 09H
LEA DX , DSTR
INT 21H
MOV AH , 4CH ; Service routine for exit
INT 21H
END