Logo 
Search:

Assembly Language Articles

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

Program to reverse a string inputted from the user

Posted By: Georgia Hughes     Category: Assembly Language     Views: 11562

A Program to reverse a string inputted from the user.

Code for Program to reverse a string inputted from the user in Assembly Language

.MODEL SMALL
.DATA
        STR1    DB      5   DUP(' '),'$'
        STR2    DB      5   DUP(' '),'$'
        NL      DB      0DH,0AH,'$'
.CODE
MAIN    PROC
        MOV AX,@DATA
        MOV DS,AX

        LEA SI,STR1
        LEA DI,STR2

        MOV AH,01H
AGAIN:
        INT 21H
        CMP AL,0DH
        JE  BAK

        MOV [SI],AL
        INC SI
        JMP AGAIN
BAK:
        MOV AL,'$'
        MOV [SI],AL

        MOV AH,09H
        LEA DX,NL
        INT 21H

        MOV CX,LENGTH STR1
        ADD CX,1
DOTHIS:
        DEC SI
        MOV AL,[SI]

        MOV [DI],AL
        INC DI
        LOOP DOTHIS

        MOV AL,'$'
        MOV [DI],AL

        MOV AH,09H

        LEA DX,NL
        INT 21H
        LEA DX,STR2
        INT 21H

        MOV AH,4CH
        INT 21H

MAIN    ENDP
END   MAIN

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

Z:\assembly\SYSTEM~1\AS1>EX7
ABC
CBA
  
Share: 


Didn't find what you were looking for? Find more on Program to reverse a string inputted from the user Or get search suggestion and latest updates.

Georgia Hughes
Georgia Hughes author of Program to reverse a string inputted from the user is from London, United Kingdom.
 
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!