Intermediate
Count Vowels
Count the number of vowels in an uppercase string.
Write a program to count the number of vowels (A, E, I, O, U) in a null-terminated string stored at x5000. Store the count in memory location x6000. Assume all letters are uppercase.
Requirements:
• Count only the characters A, E, I, O, U
• The string at x5000 is null-terminated and all uppercase
• Store the vowel count at x6000
ASCII values:
| Letter | Hex | Decimal |
|---|---|---|
| A | x41 | 65 |
| E | x45 | 69 |
| I | x49 | 73 |
| O | x4F | 79 |
| U | x55 | 85 |
Approach: For each character, subtract each vowel's ASCII value and check if the result is zero. If (char - 'A') == 0, it's an 'A'.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31