Read a line of lower-case letters and spaces and print how many of its letters are vowels (a, e, i, o, u).
Input
One line of 1 to 60 characters, each a lower-case letter or a space.
Output
The number of vowels, in decimal.
Examples
Example 1 · Input
assembly
Expected output
2
Example 2 · Input
aeiou
Expected output
5
Hints
Hint 1
Store the five vowels in the data segment: VOWELS DB 'aeiou'.
Hint 2
For each key, compare it with each of the five vowels using an index register: VOWELS[SI].
Hint 3
The count can be more than 9, so print it in decimal (AAM gives the two digits of a number below 100).
Solution
Show one correct solution (try it yourself first)
; Count the vowels
.MODEL SMALL
.STACK 100H
.DATA
VOWELS DB 'aeiou'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV BL, 0 ; the count
NEXT:
MOV AH, 1
INT 21H
CMP AL, 0DH
JE DONE
MOV SI, 0
CHECK:
CMP AL, VOWELS[SI]
JE FOUND
INC SI
CMP SI, 5
JB CHECK
JMP NEXT ; not a vowel
FOUND:
INC BL
JMP NEXT
DONE:
MOV AL, BL
AAM ; AH = tens, AL = ones
MOV BX, AX
CMP BH, 0
JE ONES
MOV DL, BH
ADD DL, '0'
MOV AH, 2
INT 21H
ONES:
MOV DL, BL
ADD DL, '0'
MOV AH, 2
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN