czy ktoś mógłby przetłumaczyć na C++ lub chociaz opisać jak działa (w miarę dokładnie) algorytm fukncji strstr która jest w standardowych bibliotekach kompilatora w asemblerze:
char * _FARFUNC strstr(const char *str1, const char *str2)
{
if (!*str2)
return((char *)str1); /* return str1 if str2 empty */
pushDS_
#if !(LDATA)
_ES = _DS;
#endif
asm cld
asm LES_ di, str1
pushES_
asm mov bx, di
asm xor ax, ax
asm mov cx, -1
asm repnz scasb
asm not cx
asm xchg cx, dx
asm LES_ di, str2
pushES_
asm mov bp, di
asm xor ax, ax
asm mov cx, -1
asm repnz scasb
asm inc cx
asm not cx
popDS_
popES_
strLoop:
asm mov si, bp
asm lodsb
asm xchg di, bx
asm xchg cx, dx
asm repnz scasb
asm mov bx, di
asm jnz NotFound
asm cmp cx, dx
asm jnb FirstMatch
NotFound:
#if (LDATA)
asm xor bx, bx
asm mov es, bx
#endif
asm mov bx, 1
asm jmp short End
FirstMatch:
asm xchg cx, dx
asm jcxz End
asm mov ax, cx
asm dec cx
asm repz cmpsb
asm mov cx, ax
asm jnz strLoop
End:
popDS_
#if (LDATA)
return (char _es *)(_BX - 1);
#else
return (char *)(_BX - 1);
#endif
}