Answered step by step
Verified Expert Solution
Question
1 Approved Answer
; program to count occurrence of letters ' o ' and ' r ' . MODEL SMALL . STACK 1 0 0 h . DATA
; program to count occurrence of letters o and r
MODEL SMALL
STACK h
DATA
txtlen DB
count DB ; to store count of o
count DB ; to store count of r
txt DB 'Enter the text of length :
newline DB $
CODE
MAIN PROC
; initialize Data Segment
MOV AX@DATA
MOV DSAX
; display prompt message
LEA DXtxt
MOV AHh
INT h
; read the text from the user
LEA DXtxt
MOV AHAh
INT h
; count occurrence of o and r
CALL COUNTOCCURRENCE
; display result
MOV DLcount
ADD DLh
MOV AHh
INT h
MOV DL
MOV AHh
INT h
MOV DLcount
ADD DLh
MOV AHh
INT h
; display new line
LEA DXnewline
MOV AHh
INT h
; return to DOS
MOV AHCh
INT h
MAIN ENDP
COUNTOCCURRENCE PROC
PUSH SI
MOV CXtxtlen
LEA SItxt
counto:
CMP SIo
JNE countr
INC count
countr:
CMP SIr
JNE nextchar
INC count
nextchar:
INC SI
LOOP counto
POP SI
RET
COUNTOCCURRENCE ENDP
END MAIN
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started