Reverse of a String - Assembly Language - MASM


REVERSE OF A STRING

Program:
.model small
.stack 200h
.data
   msg1 db 10,13,"Enter string:",10,13,'$'
   msg2 db 10,13,"Reverse of the string is:",10,13,'$'
   arr db 20 dup(?)
.code
   print MACRO msg
   PUSH AX
   PUSH DX
   MOV AH,09H
   MOV DX,offset msg
   INT 21H
   POP DX
   POP AX
   ENDM
.startup
   print msg1
   mov arr,18
   mov dx,offset arr
   mov ah,0ah
   int 21h
   lea dx,msg2
   mov ah,09h
   int 21h
   mov ch,0h
   mov cl,arr[1]
   mov di,cx
   inc di
l1:
   mov dl,arr[di]
   mov ah,02h
   int 21h
   dec di
   loop l1
  .exit
End

Output:
F:\>revv
Enter string:
PALINDROME
Reverse of the string is:
EMORDNILAP

1 comment:

  1. Good information here. I will post these information to my facebook page. It is really very informative for others.translation service

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...