Logo 
Search:

Assembly Language Articles

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

Program to find the no. of occurrences of character ‘c’ in the input string

Posted By: Adaliz Fischer     Category: Assembly Language     Views: 10469

Write a program to find the no. of occurrences of character ‘c’ in the input string.

Code for Program to find the no. of occurrences of character ‘c’ in the input string in Assembly Language

DATA SEGMENT
        MSG1 DB "ENTER THE STRING : $"
        MSG2 DB "NO OF OCCURANCES OF N : $"
        NEWLINE DB 10,13,'$'
        STR1 DB 80 DUP('$')
        CNT DB 0
DATA ENDS
CODE SEGMENT
        ASSUME DS:DATA,CS:CODE
        START :
                MOV AX,DATA
                MOV DS,AX

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

                MOV AH,0AH
                LEA DX,STR1
                INT 21H

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

                LEA SI,STR1+1
                MOV CL,BYTE PTR[SI]
                MOV CH,00H

        L1   :  INC SI

                CMP BYTE PTR[SI],'N'

                JNZ L2
                INC CNT
           L2 : LOOP L1

                ADD CNT,'0'

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

                MOV AH,02H
                MOV DH,00H
                MOV DL,CNT
                INT 21H

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

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

        ENTER THE STRING : JINESH
        NO OF OCCURANCES OF N : 1
  
Share: 



Adaliz Fischer
Adaliz Fischer author of Program to find the no. of occurrences of character ‘c’ in the input string 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!