5.38 · exercise
Count the vowels
The starter reads one line of text (the stdin box holds a famous one: it uses every letter of the alphabet). Count its vowels.
Strings are just bytes ending in a zero. Load one byte at a time with ldrb, stop at the terminator, and bump the count for every a, e, i, o, or u. Character literals like 'a' work directly in cmp, and the post-indexed form ldrb wX, [ptr], 1 loads and advances the pointer in one instruction. fgets keeps the line's newline, which is not a vowel.
What is checked
- the vowel count is printed on its own line
- the program exits cleanly
- the walk is byte by byte (
ldrbpresent, count not written in) - the same holds for other lowercase lines you do not see, an empty line and no input at all among them
specification
stdinthe quick brown fox jumps over the lazy dog
stdoutprints the right output
exitexits with the right code
sourceuses
ldrbsourcedoes not hardcode the answer
hiddenright output and exit code on 5 more inputs you do not see
We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.