Question: Write an assembly program which prompts the user for a string. The program then prints the count for each of the 26 letters of the
Write an assembly program which prompts the user for a string. The program then prints the count for each of the 26 letters of the alphabet, not distinguishing between upper case and lower case, and ignoring all non-letter characters.
Here are some example runs of the program:
Enter a string written in some language: aAAaab555 $ZZZZZzzz a:5 b:1 c:0 d:0 e:0 f:0 g:0 h:0 i:0 j:0 k:0 l:0 m:0 n:0 o:0 p:0 q:0 r:0 s:0 t:0 u:0 v:0 w:0 x:0 y:0 z:8
Note that the program prints that there are 8 zs, because it does not distinguish between Z and z and counts them as the same letter. Note also that the white spaces, and other non-letter characters are ignored.
Here is another example, just in case:
Enter a string written in some language: I'm too tired to write assembly! a:1 b:1 c:0 d:1 e:3 f:0 g:0 h:0 i:3 j:0 k:0 l:1 m:2 n:0 o:3 p:0 q:0 r:2 s:2 t:4 u:0 v:0 w:1 x:0 y:1 z:0
Implementation Constraint:
- You cannot declare more than 10 labels in your program (counting .data and .bss segment labels together). If you do youll receive no credit for the assignment.
Hints:
- Since you dont know how long the string will be, there is no way you can store it in RAM. Instead, you should do all processing on-the-fly, i.e., as each character comes in;
- Clearly its a good idea to use an array of 26 counters (the first counter is for counting occurrences of a, the second counter is for counting occurrences of b, etc.);
- Well run your code for very large input string (see questions below), so these counters should store 4-byte values to avoid overflow.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
