In case of dword div it's not so nice. It's theoretically possible to shave 1 cpu clock cycle. And i have no working example jet. Sorry, for spreading false hope.
example for byte case:
function teByteDivBy7( divided : dword):dword; assembler; nostackframe;
asm
mov ecx,divided
mov eax,293
mul ecx
shr eax, 11
end;
----- Reply to message -----
Subject: Re: [fpc-devel] The "magic div" algorithm
From: Marģers . via fpc-devel <fpc-devel@lists.freepascal.org>
To: FPC developers' list <fpc-devel@lists.freepascal.org>
Subject: Re: [fpc-devel] The "magic div" algorithm
From: Marģers . via fpc-devel <fpc-devel@lists.freepascal.org>
To: FPC developers' list <fpc-devel@lists.freepascal.org>
For unsigned byte, word and dword divisions by constant on 64 bit cpu can be converted as good cases.
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel