Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need an . asm code for finding how many places the letters ' o ' and ' r ' appear in a text containing
I need an asm code for finding how many places the letters o and r appear in a text containing charactersWrite the dosbox code asm of main procedure and sub procedure. I wrote a code but when want to emulate and create the asm file it gives the Error Anvalid nstruction Operands error. How can fix that The code that wrote is below. ; 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