Search This Blog

Tuesday, February 11, 2014

Assembly Language Program for String Manipulation in 8086 assembly language

DATA SEGMENT   
        MSG1 DB 10,13,'ENTER String :$'
        MSG2 DB 10,13,'Lenght of string is : $'
        MSG3 DB 10,13,'Reverse of String is : $'
        MSG4 DB 10,13,'Concated String is :$'
        str1 db 10 dup(0)
        str2 db 10 dup(0)
DATA ENDS

CODE SEGMENT
        ASSUME CS:CODE,DS:DATA
START:
        MOV AX,DATA
        MOV DS,AX
       
        MOV AH,09H              ;DISPLAY MESG
        LEA DX,MSG1
        INT 21H
   
        Mov si, offset str1
       
 BACK:  MOV Ah,01H            ;READ FROM KBD
        INT 21H
        mov [si], al
        inc si
        cmp al,'$'
        jnz back

        MOV AH,09H              ;DISPLAY MESG
        LEA DX,MSG1
        INT 21H
   
        Mov si, offset str2
       
 BACK1:  MOV Ah,01H            ;READ FROM KBD
        INT 21H
        mov [si], al
        inc si
        cmp al,'$'
        jnz back1


        Mov si, offset str1
 next:
      mov al,[si]
      inc si
      cmp al,'$'    
      jnz next               
     
     DEC si
     
     
      Mov di, offset str2
backward:
      mov al,[di]  
      mov [si],al
      inc si
      inc di
      cmp al,'$'
      jnz backward

          
      MOV AH,09H              ;DISPLAY MESG
      LEA DX,MSG4
      INT 21H
      MOV AH,09H              ;DISPLAY MESG
      LEA DX,str1
      INT 21H



      MOV AH,4CH
      INT 21H

CODE ENDS
END START
END




1 comment: