ALP to reverse a string

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
fstr db "SANTOSH",'$'
slen dw $-fstr  ;now slen has a value of 7+1=8
rstr db 20 dup (?)
DATA ENDS

CODE SEGMENT
START:
 MOV AX,DATA
 MOV DS,AX
 MOV ES,AX

 LEA SI,FSTR
 LEA DI,RSTR
 MOV CX,SLEN
 DEC CX
 DEC CX

 ADD SI,CX
 MOV CX,SLEN
 DEC CX

L:
 MOV DX,[SI]
 DEC SI
 MOV [DI],DX
 INC DI
 LOOP L

 MOV AL,'$'
 MOV [DI],AL
 LEA DX,RSTR
 MOV AH,09H
 INT 21H

 MOV AH,4CH
 INT 21H
CODE ENDS
END START

Comments

Popular posts from this blog

ALP to demonstrate shift operations

ALP to transfer a block of data from one location to another

Fibonacci series to display first 5 terms