mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 11:45:32 +02:00
IndexWord and IndexDWord for i386 without REP SCAS.
This commit is contained in:
parent
64319dc019
commit
71863e1b2c
@ -459,35 +459,34 @@ end;
|
|||||||
|
|
||||||
{$ifndef FPC_SYSTEM_HAS_INDEXWORD}
|
{$ifndef FPC_SYSTEM_HAS_INDEXWORD}
|
||||||
{$define FPC_SYSTEM_HAS_INDEXWORD}
|
{$define FPC_SYSTEM_HAS_INDEXWORD}
|
||||||
function IndexWord_Plain(Const buf;len:SizeInt;b:word):SizeInt; assembler;
|
function IndexWord_Plain(Const buf;len:SizeInt;b:word):SizeInt; assembler; nostackframe;
|
||||||
var
|
|
||||||
saveedi,saveebx : longint;
|
|
||||||
asm
|
asm
|
||||||
movl %edi,saveedi
|
push %eax
|
||||||
movl %ebx,saveebx
|
cmp $1073741823, %edx
|
||||||
movl Buf,%edi // Load String
|
ja .LUnbounded
|
||||||
movw b,%bx
|
lea (%eax,%edx,2), %edx
|
||||||
movl Len,%ecx // Load len
|
cmp %edx, %eax
|
||||||
xorl %eax,%eax
|
je .LNotFound
|
||||||
testl %ecx,%ecx
|
.LWordwise_Body:
|
||||||
jz .Lcharposnotfound
|
cmp %cx, (%eax)
|
||||||
{$ifdef FPC_ENABLED_CLD}
|
je .LFound
|
||||||
cld
|
add $2, %eax
|
||||||
{$endif FPC_ENABLED_CLD}
|
cmp %edx, %eax
|
||||||
movl %ecx,%edx // Copy for easy manipulation
|
jne .LWordwise_Body
|
||||||
movw %bx,%ax
|
.LNotFound:
|
||||||
repne
|
pop %eax
|
||||||
scasw
|
mov $-1, %eax
|
||||||
jne .Lcharposnotfound
|
ret
|
||||||
incl %ecx
|
|
||||||
subl %ecx,%edx
|
.LFound:
|
||||||
movl %edx,%eax
|
pop %edx
|
||||||
jmp .Lready
|
sub %edx, %eax
|
||||||
.Lcharposnotfound:
|
shr $1, %eax
|
||||||
movl $-1,%eax
|
ret
|
||||||
.Lready:
|
|
||||||
movl saveedi,%edi
|
.LUnbounded:
|
||||||
movl saveebx,%ebx
|
mov %eax, %edx
|
||||||
|
jmp .LWordwise_Body
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IndexWord_SSE2(const buf;len:SizeInt;b:word):SizeInt; assembler; nostackframe;
|
function IndexWord_SSE2(const buf;len:SizeInt;b:word):SizeInt; assembler; nostackframe;
|
||||||
@ -626,35 +625,34 @@ end;
|
|||||||
|
|
||||||
{$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
|
{$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
|
||||||
{$define FPC_SYSTEM_HAS_INDEXDWORD}
|
{$define FPC_SYSTEM_HAS_INDEXDWORD}
|
||||||
function IndexDWord_Plain(Const buf;len:SizeInt;b:DWord):SizeInt; assembler;
|
function IndexDWord_Plain(Const buf;len:SizeInt;b:DWord):SizeInt; assembler; nostackframe;
|
||||||
var
|
|
||||||
saveedi,saveebx : longint;
|
|
||||||
asm
|
asm
|
||||||
movl %edi,saveedi
|
push %eax
|
||||||
movl %ebx,saveebx
|
cmp $536870911, %edx
|
||||||
movl %eax,%edi
|
ja .LUnbounded
|
||||||
movl %ecx,%ebx
|
lea (%eax,%edx,4), %edx
|
||||||
movl %edx,%ecx
|
cmp %edx, %eax
|
||||||
xorl %eax,%eax
|
je .LNotFound
|
||||||
testl %ecx,%ecx
|
.LDWordwise_Body:
|
||||||
jz .Lcharposnotfound
|
cmp %ecx, (%eax)
|
||||||
{$ifdef FPC_ENABLED_CLD}
|
je .LFound
|
||||||
cld
|
add $4, %eax
|
||||||
{$endif FPC_ENABLED_CLD}
|
cmp %edx, %eax
|
||||||
movl %ecx,%edx // Copy for easy manipulation
|
jne .LDWordwise_Body
|
||||||
movl %ebx,%eax
|
.LNotFound:
|
||||||
repne
|
pop %eax
|
||||||
scasl
|
mov $-1, %eax
|
||||||
jne .Lcharposnotfound
|
ret
|
||||||
incl %ecx
|
|
||||||
subl %ecx,%edx
|
.LFound:
|
||||||
movl %edx,%eax
|
pop %edx
|
||||||
jmp .Lready
|
sub %edx, %eax
|
||||||
.Lcharposnotfound:
|
shr $2, %eax
|
||||||
movl $-1,%eax
|
ret
|
||||||
.Lready:
|
|
||||||
movl saveedi,%edi
|
.LUnbounded:
|
||||||
movl saveebx,%ebx
|
mov %eax, %edx
|
||||||
|
jmp .LDWordwise_Body
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IndexDWord_SSE2(const buf;len:SizeInt;b:DWord):SizeInt; assembler; nostackframe;
|
function IndexDWord_SSE2(const buf;len:SizeInt;b:DWord):SizeInt; assembler; nostackframe;
|
||||||
|
Loading…
Reference in New Issue
Block a user