Right now I’m trying to load a null-terminated string and return the number of alphabetic characters that are in that string. Currently I have three functions: the Main, countAlpha (which is intended to count the number of characters), and isAlpha, which determines whether the character is alphabetic or not. I would like some help with my algorithm.
So, for my Main I load the string, jump and link to countAlpha, and then load the syscall commands to print int and exit the program.
For my countAlpha, which I am having trouble with, I want to create a for loop that goes through each character in the string and if isAlpha returns a 1 (indicating that the character is alphabetic), then increase the count.
isAlpha is straightforward-just determine if the character is between specific numbers in ASCII.
So I guess my question is how do I attack countAlpha. Thanks for your help. (Note: I don’t want actual code, just tips and hints)
Sounds like you want to test a return value / register for the call to isAlpha and add/increment a seperate register/count var everytime the test is true. Or you could just add the return value directly to your count register every time through the loop if the value is returned as a 0 or 1. Then, just setup your loop to keep going until the current character is a ‘\0’ char. Then your count register holds your final value.
Is this in-depth enough to help you out?