Logo 
Search:

Assembly Language Articles

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

Program to concatenate two strings INSTR1 and INSTR2 and store the result in the string INSTR1

Posted By: Adelmo Fischer     Category: Assembly Language     Views: 10587

Write a program to concatenate two strings INSTR1 and INSTR2 and store the result in the string INSTR1.

Code for Program to concatenate two strings INSTR1 and INSTR2 and store the result in the string INSTR1 in Assembly Language

DATA SEGMENT
        STR1 DB "ENTER FIRST STRING HERE ->$"
        STR2 DB "ENTER SECOND STRING HERE ->$"
        STR3 DB "CONCATED STRING :->$"
        STR11 DB "FIRST STRING : ->$"
        STR22 DB "SECOND STRING: ->$"

        INSTR1 DB 20 DUP("$")
        INSTR2 DB 20 DUP("$")
        N DB ?
        N1 DB ?
        NEWLINE DB 10,13,"$"

DATA ENDS

CODE SEGMENT

        ASSUME DS:DATA,CS:CODE
START:

        MOV AX,DATA
        MOV DS,AX

        LEA SI,INSTR1
        LEA DI,INSTR2

;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

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

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


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


;PRINT THE STRING

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

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

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

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

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

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

;CONCATINATION OF THE STRING

        LEA SI,INSTR1
        LEA DI,INSTR2
        MOV CX,00

        INC SI

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

        ADD DI,2
        MOV BX,0
      L2:
       
        MOV BL,BYTE PTR[DI]
        MOV BYTE PTR[SI],BL
        
        INC SI
        INC DI

        CMP BYTE PTR[DI],"$"

        JNE L2

     L8:DEC SI
        CMP SI,2
        JNE L8

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

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

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



     L6:
        MOV BL,BYTE PTR[SI]

        MOV AH,02H
        MOV DL,BL
        INT 21H

        INC SI
        CMP BYTE PTR[SI],"$"
        JNE L6

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

        MOV AH,4CH
        INT 21H


CODE ENDS
END START
  
Share: 



Adelmo Fischer
Adelmo Fischer author of Program to concatenate two strings INSTR1 and INSTR2 and store the result in the string INSTR1 is from Frankfurt, Germany.
 
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].

 
No Comment Found, Be the First to post comment!