Answered step by step
Verified Expert Solution
Link Copied!

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 100h
.DATA
txt_len DB 200
count1 DB 0 ; to store count of 'o'
count2 DB 0 ; to store count of 'r'
txt DB 'Enter the text of length 200:'
newline DB 13,10,'$'
.CODE
MAIN PROC
; initialize Data Segment
MOV AX,@DATA
MOV DS,AX
; display prompt message
LEA DX,txt
MOV AH,09h
INT 21h
; read the text from the user
LEA DX,txt
MOV AH,0Ah
INT 21h
; count occurrence of 'o' and 'r'
CALL COUNT_OCCURRENCE
; display result
MOV DL,count1
ADD DL,30h
MOV AH,02h
INT 21h
MOV DL,''
MOV AH,02h
INT 21h
MOV DL,count2
ADD DL,30h
MOV AH,02h
INT 21h
; display new line
LEA DX,newline
MOV AH,09h
INT 21h
; return to DOS
MOV AH,4Ch
INT 21h
MAIN ENDP
COUNT_OCCURRENCE PROC
PUSH SI
MOV CX,txt_len
LEA SI,txt+2
count_o:
CMP [SI],'o'
JNE count_r
INC count1
count_r:
CMP [SI],'r'
JNE next_char
INC count2
next_char:
INC SI
LOOP count_o
POP SI
RET
COUNT_OCCURRENCE ENDP
END MAIN

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

What kind of expense is an electric bill? CapEx TCO OpEx KPI

Answered: 1 week ago

Question

to encourage a drive for change by developing new ideas;

Answered: 1 week ago

Question

4 What are the alternatives to the competences approach?

Answered: 1 week ago