Logo 
Search:

Assembly Language Articles

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

Write a Program to reverse a string

Posted By: Ella Campbell     Category: Assembly Language     Views: 19362

Write a Program to reverse a string.

Code for Write a Program to reverse a string in Assembly Language

Data Segment
  str1 db 'String_Reverse','$'  
  strlen1 dw $-str1
  strrev db 20 dup(' ')
Data Ends

Code Segment
  Assume cs:code, ds:data
  Begin:
    mov ax, data
    mov ds, ax
    mov es, ax
    mov cx, strlen1
    add cx, -2
    lea si, str1
    lea di, strrev
    add si, strlen1
    add si, -2
    L1:
       mov al, [si]
       mov [di], al
       dec si
       inc di
       loop L1
       mov al, [si]
       mov [di], al
       inc di
       mov dl, '$'
       mov [di], dl
    Print:
       mov ah, 09h
       lea dx, strrev
       int 21h
    Exit:
       mov ax, 4c00h
       int 21h
Code Ends
End Begin

  
Share: 


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

Ella Campbell
Ella Campbell author of Write a Program to reverse a string is from Toronto, Canada.
 
View All Articles

 
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!