Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

PROGRAM TO FIND THE REVERSE OF A STRING USING MACRO

Posted By: Ludwig Fischer     Category: Assembly Language     Views: 5362

A PROGRAM TO FIND THE REVERSE OF A STRING USING MACRO.

Code for PROGRAM TO FIND THE REVERSE OF A STRING USING MACRO in Assembly Language

GETSTR MACRO STR
MOV AH,0AH
LEA DX,STR
INT 21H
ENDM

PRINTSTR MACRO STR
MOV AH,09H
LEA DX,STR
INT 21H
ENDM


DATA SEGMENT
    STR1 DB 80,80 DUP('$')
    STR2 DB 80,80 DUP('$')
    MSG1 DB 10,13,'ENTER THE STRING :$'
    MSG2 DB 10,13,'THE REVERSE STRING IS :$'
    STORE DB 2 DUP('$')
DATA ENDS


CODE SEGMENT

        ASSUME CS:CODE,DS:DATA
        START:

                 MOV AX,DATA
                 MOV DS,AX

                 PRINTSTR MSG1
                 GETSTR STR1
                 PRINTSTR MSG2
        
                 LEA SI,STR1+2
                 LEA DI,STR2+2
        
                 MOV CL,STR1+1    ;FOR STORING THE LENGTH OF THE STRING
                 MOV CH,00H
                 MOV BL,CL
                 MOV BH,00H
        
         LAB1:
                 INC SI           ;FOR GOING TO THE END OF THE STRING
                 LOOP LAB1

                 MOV CX,BX

         LAB2:
                 MOV AL,DS:BYTE PTR[SI] ;FOR COPYING CONTENTS OF STR1 TO AL
                 MOV DS:BYTE PTR[DI],AL ;FOR COPYING CONTENTS OF AL TO STR2
                 INC DI
                 DEC SI
                 LOOP LAB2
           
         PRINTSTR STR2+2       
         MOV AH,DS:BYTE PTR[SI]
         MOV STORE,AH
         PRINTSTR STORE

           
         MOV AX,4C00H
         INT 21H

CODE ENDS
        END START

OUTPUT
***********

D:\tasm\tasm1>m1

ENTER THE STRING :abc
cba REVERSE STRING IS 
 
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM TO FIND THE REVERSE OF A STRING USING MACRO Or get search suggestion and latest updates.

Ludwig Fischer
Ludwig Fischer author of PROGRAM TO FIND THE REVERSE OF A STRING USING MACRO is from Frankfurt, Germany.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!