Answered step by step
Verified Expert Solution
Link Copied!

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 200characters.Write the dosbox 8086code (. 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 A2070nvalid 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 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_2

Step: 3

blur-text-image_3

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

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions