Objectives:
1. Write procedures using strings as arguments.
2. Apply pointers.
3. Write user-defined procedures.
4. Apply user-defined procedures.
5. Apply loops.
Problem Description:
Write a procedure named Str_find that searches for the first matching occurrence of a source string inside a target string and returns the matching position. The input parameters should be a pointer to the source string and a pointer to the target string. If a match is found, the procedure sets the Zero flag and EAX points to the matching position in the target string. Otherwise, the Zero flag is clear and EAX is undefined. The following code, for example, searches for "ABC" and returns with EAX pointing to the "A" in the target string.
.data
Target BYTE "123ABC342342", 0
Source BYTE "ABC", 0
Pos DWORD ?
.code
INVOKE Str_find, ADDR Source, ADDR Target
Jnz notFound
Mov Pos, eax ; store the position value
Extra Credit:
You may notice that in my solution, I only take lowercase y/n because I used "call ReadChar" and "call WriteChar" to get the user's choice and display the user's choice. If the user tries to type a capital Y, the program will exit since it will read the "shift" key as the user's input. Any input different from lowercase y will be considered a NO choice.
Modify your solution so that it can handle the following two cases:
1. It can take uppercase letters as the user's choice.
2. If the user's choice is NOT Y, y, N, or n, prompt an error message and ask the user to reenter their choice.
This is worth 2% overall extra credit. There is no curve for this class. If you want one, do this extra credit so you get a 2% curve!