LOOKING FOR A BETTER WAY TO WRITE THIS METHOD thanks , ASSEMBLY LANGUAGE getVowe
ID: 655850 • Letter: L
Question
LOOKING FOR A BETTER WAY TO WRITE THIS METHOD thanks , ASSEMBLY LANGUAGE
getVowels PROC
;FIND TOTAL COUNT OF VOWELS
mov edx,OFFSET prompt1 ;Input paragraph, to end enter '%'
call WriteString
mov number_of_words,1
mov number_of_Sent,1
mov number_of_sletters,0
mov number_of_characters,0
mov number_of_vowels,0
mov number_of_capitals,1
L1:
call ReadChar
call displayEvry
cmp AL,Sentinel ;%-to calculate
jne NOT_QUITF
mov edx,OFFSET prompt2 ;'%' Found. End of paragraph
call WriteString
jmp QUITF ;display result procedure
NOT_QUITF:
cmp AL,'A'
jne NOT_A
inc number_of_vowels
NOT_A:
cmp AL,'a'
jne NOT_aa
inc number_of_vowels
NOT_aa:
cmp AL,'E'
jne NOT_E
inc number_of_vowels
NOT_E:
cmp AL,'e'
jne NOT_ee
inc number_of_vowels
NOT_ee:
cmp AL,'I'
jne NOT_I
inc number_of_vowels
NOT_I:
cmp AL,'i'
jne NOT_ii
inc number_of_vowels
NOT_ii:
cmp AL,'O'
jne NOT_O
inc number_of_vowels
NOT_O:
cmp AL,'o'
jne NOT_oo
inc number_of_vowels
NOT_oo:
cmp AL,'U'
jne NOT_U
inc number_of_vowels
NOT_U:
cmp AL,'u'
jne NOT_VOWEL_FLAG
inc number_of_vowels
NOT_VOWEL_FLAG:
jmp L1
QUITF: ;display result procedure:
call DISP_VOW
getVowels ENDP
Explanation / Answer
.707
.MODEL flat, stdcall
.STACK
INCLUDE Irvine32.inc
.data
OFFSET BYTE 100 DUP('$') ;
Vowels BYTE "AEIOU aeiou",0
prompt1 BYTE "Enter a string (max 20 chars): ",0
COUNT DWORD ?
str1 BYTE "The number of vowels in given string: ",0
.code
main PROC
call Clrscr
; Display prompt1
lea edx, prompt1
call WriteString
; Read a null-terminated string from standard input
lea edx, OFFSET ; edx = address of storage area for string
mov ecx, SIZEOF OFFSET ; ecx = max characters to be stored
call ReadString ; read string from standard input
MOV AX,OFFSET
MOV DS, AX
MOV CX, 00
MOV DI, 00
MOV AX, 00
LEA DX, MAXLEN
MOV AH, 0AH
INT 21H
MOV CH, 00H
L2: MOV SI, 000BH
L1: MOV AL, Vowels[SI]
CMP AL, OFFSET [DI]
JNZ L3
INC DH
CMP DH, 0AH
JB L3
MOV DH, 00
INC DL
L3: SUB SI, 01
JNZ L1
INC DI
LOOP L2
MOV BX, DX
MOV AH, 02H
MOV DL, 0AH
INT 21H
MOV DL, 0DH
INT 21H
LEA DX, str1
MOV AH, 09H
INT 21H
MOV DX, bX
ADD DL, 30H
MOV AH, 02H
INT 21H
ADD DH, 30H
MOV DL, DH
MOV AH, 02H
INT 21H
MOV AX, 4C00H
INT 21H
exit
main ENDP
END main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.