Answer:
Str_nextword PROC, pString:PTR BYTE, ; pointer to string delimiter:BYTE ; delimiter to find push esi mov al,delimiter mov esi,pString cld ; clear Direction flag (forward) L1: lodsb ; AL = [esi], inc(esi) cmp al,0 ; end of string? je L3 ; yes: exit with ZF = 0 cmp al,delimiter ; delimiter found? jne L1 ; no: repeat loop L2: mov BYTE PTR [esi-1],0 ; yes: insert null byte mov eax,esi ; point EAX to next character jmp Exit_proc ; exit with ZF = 1 L3: or al,1 ; clear Zero flag Exit_proc: pop esi ret Str_nextword ENDP
Explanation:
push esimov al,delimitermov esi,pStringcld ; clear Direction flag (forward)L1: lodsb ; AL = [esi], inc(esi)cmp al,0 ; end of string?je L3 ; yes: exit with ZF = 0cmp al,delimiter ; delimiter found?jne L1 ; no: repeat loopL2: mov BYTE PTR [esi-1],0 ; yes: insert null bytemov eax,esi ; point EAX to next characterjmp Exit_proc ; exit with ZF = 1L3: or al,1 ; clear Zero flagExit_proc:pop esiretStr_nextword ENDPStr_nextword ENDP