Question: 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.
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 "123ABC342432",0 source BYTE "ABC",0 pos DWORD ?
.code INVOKE Str_find, ADDR source, ADDR target jnz notFound mov pos,eax ; store the position value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
