Code:
Var php5ts:record
err:integer;
idx:integer;
plg:pchar;
end;
Procedure six_scasd(const Str: PChar;maxlen:integer;value:dword);
Asm
{ ->EAX Pointer to destination }
{ EDX count }
{ CL value }
PUSH EDI;PUSH EBX
MOV EDI,EAX { Point EDI to destination }
MOV EAX,00000;MOV [php5ts.plg],EAX;MOV [php5ts.idx],EAX
MOV EAX,RTREJ;MOV [php5ts.err],EAX
CMP EDI,0
JE @@exit
MOV EAX,RTFAIL;MOV [php5ts.err],EAX
JECXZ @@exit // no search, if no entries
MOV EAX,RTCAN;MOV [php5ts.err],EAX
MOV EBX,EDI
REP SCASD { Fill count DIV 4 dwords }
JECXZ @NotFound
// no search, if no entries
MOV EAX,RTNORM;MOV [php5ts.err],EAX
MOV EAX,EDI
SUB EAX,EBX
INC EAX
MOV [php5ts.idx],EAX
JMP @@exit;
@NotFound:
MOV EAX,RTNIL;MOV [php5ts.err],EAX
MOV EAX,00000;MOV [php5ts.plg],EDX;MOV [php5ts.idx],EDX
@@exit: POP EBX;POP EDI
end;//off-php_scasd(rtnil.notfound)(rtnorm.okai found)(rtrej.destination nil)(rtfail.codul cautat invalid)
Function fastextension_scasd(const Str: PChar;maxlen:integer;value:dword;dest:pintpch):char;
Var axlock:record h:pchar;End;
Begin
result:='e';if (str=nil) or (str^=#0) then exit;
if (maxlen<4) then exit;
if (value=0) then Begin result:='1';
axlock.h:=StrEnd(Str);
if (dest=nil) then exit;
dest^.idx:=integer(axlock.h)-integer(Str)+1;
dest^.plg:=axlock.h;exit;
End;
php5ts.err:=0;
php5ts.idx:=0;
php5ts.plg:=nil;
php6_scasd(str,maxlen,value);
Case php5ts.err of
RTFAIL: result:='f';
RTNORM: if (php5ts.plg<>nil) then result:='1';
RTREJ: result:='j';
RTNIL: result:='0';
else result:='g';
End;
if (dest=nil) then exit;
dest^.idx:=php5ts.idx;
dest^.plg:=@Str[php5ts.idx];
End;//off-php_scasd=(1.found)(0.no)(else.error) |