Convert str_int to ATT assembler and activate it.

git-svn-id: trunk@9659 -
This commit is contained in:
daniel 2008-01-06 21:29:31 +00:00
parent f1fee20938
commit 6e2af37c48

View File

@ -1096,21 +1096,19 @@ end;
Str() Str()
****************************************************************************} ****************************************************************************}
{$ifdef disabled}
{$define FPC_SYSTEM_HAS_INT_STR_LONGWORD} {$define FPC_SYSTEM_HAS_INT_STR_LONGWORD}
{$define FPC_SYSTEM_HAS_INT_STR_LONGINT} {$define FPC_SYSTEM_HAS_INT_STR_LONGINT}
label str_int_shortcut; label str_int_shortcut;
{$asmmode intel}
procedure int_str(l:longword;out s:string);assembler;nostackframe; procedure int_str(l:longword;out s:string);assembler;nostackframe;
asm asm
push edi pushl %edi
push ebx pushl %ebx
mov edi,edx mov %edx,%edi
xor edx,edx xor %edx,%edx
jmp str_int_shortcut jmp str_int_shortcut
end; end;
@ -1123,51 +1121,49 @@ const digits:array[0..9] of cardinal=(0,10,100,1000,10000,
100000000,1000000000); 100000000,1000000000);
asm asm
push edi push %edi
push ebx push %ebx
mov edi,edx movl %edx,%edi
{ Calculate absolute value and put sign in edx} { Calculate absolute value and put sign in edx}
cdq cltd
xor eax,edx xorl %edx,%eax
sub eax,edx subl %edx,%eax
neg edx negl %edx
str_int_shortcut: str_int_shortcut:
{Calculate amount of digits in ecx.} {Calculate amount of digits in ecx.}
bsr ecx,eax bsrl %eax,%ecx
inc ecx incl %ecx
imul ecx,1233 imul $1233,%ecx
shr ecx,12 shr $12,%ecx
cmp eax,[digits+4*ecx] cmpl digits(,%ecx,4),%eax
cmc cmc
adc ecx,0 {Nr. digits ready in ecx.} adcl $0,%ecx {Nr. digits ready in ecx.}
{Write length & sign.} {Write length & sign.}
lea ebx,[edx+ecx] lea (%edx,%ecx),%ebx
mov bh,'-' movb $45,%bh {movb $'-,%bh Not supported by our ATT reader.}
mov [edi],bx movw %bx,(%edi)
add edi,edx addl %edx,%edi
{Write out digits.} {Write out digits.}
mov edx,eax movl %eax,%edx
@loop: .Lloop:
mov eax,$cccccccd {Divide by 10 using mul+shr} movl $0xcccccccd,%eax {Divide by 10 using mul+shr}
lea ebx,[edx+'0'] {Pre-add '0'} {Pre-add '0'}
mul edx leal 48(%edx),%ebx {leal $'0(,%edx),%ebx Not supported by our ATT reader.}
shr edx,3 mull %edx
lea eax,[8*edx+edx] {x mod 10 = x-10*(x div 10)} shrl $3,%edx
sub ebx,edx leal (%edx,%edx,8),%eax {x mod 10 = x-10*(x div 10)}
sub ebx,eax subl %edx,%ebx
mov [edi+ecx],bl subl %eax,%ebx
dec ecx movb %bl,(%edi,%ecx)
jnz @loop decl %ecx
pop ebx jnz .Lloop
pop edi popl %ebx
popl %edi
end; end;
{$asmmode att}
{$endif disabled}
{**************************************************************************** {****************************************************************************
Bounds Check Bounds Check
****************************************************************************} ****************************************************************************}