[fpc-devel] Math.DivMod results should be signed
Kai Olav Fredriksen
k at i.fredriksen.net
Thu Nov 9 12:12:19 CET 2006
It got beautiful with CDQ. And faster, more than twice as fast as using div
then mod (in my environment)
function DivWithRemainder(Value, Divisor: Integer; out Remainder: Integer):
Integer;
{In:
EAX = Value
EDX = Divisor
Out:
EAX = Result
ECX = @Remainder}
asm
PUSH EBX { Save EBX - this register is not free to use }
MOV EBX , EDX { Copy Divisor to EBX, using it as a store }
CDQ { Convert EAX to 64-bit EDX:EAX }
IDIV EBX { Divides Value (actually EDX:EAX)) by EBX.
Result -> EAX, remainder -> EDX }
MOV [ECX], EDX { Copies EDX to ECX^ (Remainder) }
POP EBX { Restore EBX }
end;
----- Original Message -----
From: "Florian Klaempfl" <florian at freepascal.org>
To: <k at i.fredriksen.net>; "FPC developers' list"
<fpc-devel at lists.freepascal.org>
Sent: Thursday, November 09, 2006 8:42 AM
Subject: Re: [fpc-devel] Math.DivMod results should be signed
> Is this really faster than using CDQ?
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.409 / Virus Database: 268.14.0/524 - Release Date: 08.11.2006
>
>
More information about the fpc-devel
mailing list