Search This Blog

Tuesday, February 11, 2014

Program to find out Lenght of String 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


     ; code to find out lenght
      mov ch,00h
      Mov si, offset str1
 next:
      inc ch
      mov al,[si]
      inc si
      cmp al,'$'    
      jnz next

      add ch,'0'

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

      mov ah, 2
      mov dl, ch
      int 21h

      MOV AH,4CH
      INT 21H

CODE ENDS
END START
END




No comments:

Post a Comment