Re: String Functions
- From: "Aleksandr Sharahov" <alsha-on-mail333.com>
- Date: Sun, 1 May 2005 00:42:46 +0400
Hi John,
> Yes, but maybe the inner loop could be replaced by some ASM
> code (something like Andreas Hausladen's SmallDivMod
> routine) to make it even faster. --JohnH
I had modified your function using my DivMod10.
--
regards
Aleksandr
function DivMod10_Sha(c: cardinal; var d: cardinal): cardinal; overload;
asm
push edx
mov edx, $CCCCCCCD
mov ecx, eax
mul edx
xor ecx, edx
mov eax, edx
and ecx, 1
and eax, 7
jnz @nzero
test ecx, ecx
jz @zero
@nzero:
sub eax, ecx
add eax, 2
@zero:
pop ecx
shr edx, 3
mov [ecx], edx
end;
function DivMod10_Sha(var Value: cardinal): cardinal; overload;
asm
push eax
mov eax, [eax]
mov edx, $CCCCCCCD
mov ecx, eax
mul edx
xor ecx, edx
mov eax, edx
and ecx, 1
and eax, 7
jnz @nzero
test ecx, ecx
jz @zero
@nzero:
sub eax, ecx
add eax, 2
@zero:
pop ecx
shr edx, 3
mov [ecx], edx
end;
function IntToStr_Sha(Value: integer): string;
var
Buffer: array [0..11] of char;
Negative, Blank: integer;
begin;
Negative:=0;
if Value<0 then begin;
Negative:=-1;
Value:=-Value;
end;
Blank:=High(Buffer);
repeat;
Buffer[Blank]:=char(ord('0')+DivMod10_Sha(cardinal(Value)));
dec(Blank);
until Value=0;
Buffer[Blank]:='-';
Blank:=Blank+Negative;
SetString(Result,pchar(@Buffer[Blank+1]),High(Buffer)-Blank);
end;
.
- References:
- String Functions
- From: Chekcin
- Re: String Functions
- From: Dennis
- Re: String Functions
- From: Florent Ouchet
- Re: String Functions
- From: John Herbster
- Re: String Functions
- From: Florent Ouchet
- Re: String Functions
- From: John Herbster
- String Functions
- Prev by Date: Re: String Functions
- Next by Date: Re: String Functions
- Previous by thread: Re: String Functions
- Next by thread: Re: String Functions
- Index(es):
Relevant Pages
|