DATA SEGMENT
STR1 DB "ENTER FIRST STRING HERE ->$"
STR2 DB "OCCURENCE OF C IS : ->$"
STR11 DB "GIVEN STRING IS : ->$"
OCC DB "C"
N DB ?
INSTR1 DB 20 DUP("$")
NEWLINE DB 10,13,"$"
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,INSTR1
;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
;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
;FIND THE OCCURENCE OF C
MOV AX,00
MOV AH,09H
LEA DX,STR2
INT 21H
MOV BX,00
ADD SI,1
L2:INC SI
CMP BYTE PTR[SI],"$"
JE L1
CMP BYTE PTR[SI],"C"
JNE L2
ADD BL,1
JMP L2
L1: MOV AH,09H
LEA DX,NEWLINE
INT 21H
ADD BL,30H
MOV AH,02H
MOV DL,BL
INT 21H
MOV AH,09H
LEA DX,NEWLINE
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
;OUTPUT:-
;Z:\SEM3\SS\21-30>P30
;ENTER FIRST STRING HERE ->JINESH
;GIVEN STRING IS : ->JINESH
;OCCURENCE OF C IS : ->
;0
;
;Z:\SEM3\SS\21-30>P30
;ENTER FIRST STRING HERE ->CAPITAL
;GIVEN STRING IS : ->CAPITAL
;OCCURENCE OF C IS : ->
;1