Logo 
Search:

Assembly Language Articles

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

Program to find the length of a string Use subroutine

Posted By: Connor Evans     Category: Assembly Language     Views: 7731

Write a program to find the length of a string use subroutine.

Code for Program to find the length of a string Use subroutine in Assembly Language

DIS MACRO STR
        MOV AH,09H
        LEA DX,STR
        INT 21H
ENDM

DATA SEGMENT
MSG1 DB "ENTER STRING : $"
MSG2 DB "THE LENGTH OF STRING IS : $"
STR1 DB "HARDIK$"
LINE DB 10,13,'$'
DATA ENDS
CODE SEGMENT
           LENGTH1 PROC NEAR
                   ASSUME CS:CODE
                   MOV CL,00

                   MOV AH,'$'
                L1:CMP BYTE PTR[SI],AH
                   JE L2
                   INC CL
                   INC SI
                   JMP L1
           L2:RET
           LENGTH1 ENDP
           ASSUME DS:DATA,CS:CODE
START:
        MOV AX,DATA
        MOV DS,AX
        DIS MSG1
        DIS STR1
        DIS LINE
        DIS MSG2
        LEA SI,STR1

        CALL LENGTH1

        ADD CL,'0'
        MOV AH,02H
        MOV DL,CL
        INT 21H

        MOV AH,4CH
        INT 21H 
CODE ENDS
END START

;------
;OUTPUT
;------

    ENTER STRING : JINESH
    THE LENGTH OF STRING IS : 6
  
Share: 


Didn't find what you were looking for? Find more on Program to find the length of a string Use subroutine Or get search suggestion and latest updates.

Connor Evans
Connor Evans author of Program to find the length of a string Use subroutine is from London, United Kingdom.
 
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!