Logo 
Search:

Assembly Language Articles

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

Program to copy one string into another string

Posted By: Ethan Bouchard     Category: Assembly Language     Views: 8306

Write a program to copy one string into another string.

Code for Program to copy one string into another string in Assembly Language

DATA SEGMENT
        STR1 DB "ENTER YOUR STRING HERE ->$"
        STR2 DB "YOUR STRING IS ->$"
        STR3 DB "COPIED STRING IS ->$"
        INSTR1 DB 20 DUP("$")
        CSTR DB 20 DUP("$")
        NEWLINE DB 10,13,"$"
        N DB ?
        S DB ?

DATA ENDS

CODE SEGMENT
        ASSUME DS:DATA,CS:CODE
START:

        MOV AX,DATA
        MOV DS,AX

        LEA SI,INSTR1

;GET STRING
        MOV AH,09H
        LEA DX,STR1
        INT 21H

        MOV AH,0AH
        MOV DX,SI
        INT 21H


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

;PRINT THE STRING

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

        MOV AH,09H
        LEA DX,INSTR1+2
        INT 21H

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

;PRINT THE COPIED STRING

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

        MOV CL,INSTR1+1
        ADD CL,1
        ADD SI,2

        LEA DI,CSTR


     L1:
        MOV BL,BYTE PTR[SI]
        MOV BYTE PTR[DI],BL

        INC SI
        INC DI
        CMP BYTE PTR[SI],"$"
        JNE L1


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

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


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

        MOV AH,4CH
        INT 21H


CODE ENDS
END START

;OUTPUT:-
;Z:\SEM3\SS\21-30>P27
;ENTER YOUR STRING HERE ->JINESH
;YOUR STRING IS ->JINESH
;COPIED STRING IS ->
;JINESH
  
Share: 


Didn't find what you were looking for? Find more on Program to copy one string into another string Or get search suggestion and latest updates.

Ethan Bouchard
Ethan Bouchard author of Program to copy one string into another string is from Montreal, Canada.
 
View All Articles

Related Articles and Code:


 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

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

 
Hadi Mohammadi from Islamic Republic Of Iran Comment on: Apr 26
Very Goooooooooooooooooooooooooood !
tanks for all posts!!!
Goooooooooood luck...

View All Comments