[fpc-pascal] Converting 32bit intel asm to Pascal or 64bit at&t asm
AndrewD207 at aol.com
Fri Mar 11 00:17:25 CET 2011
On 03/09/11 14:18, Thomas Schatzl wrote:
> On Wed, 09 Mar 2011 13:23:55 -0500, Andrew Haines wrote:
>> On 03/09/11 12:26, Thomas Schatzl wrote:
>>> FYL2X calculates the log to the base 2 of tmp, not log to the base e of
>>> tmp? Just a guess.
>> I originally used log2(Tmp) but switched to ln to check if it was
>> correct. Thanks for noticing that, I changed it back to log2.
> Suffixes for gas for floating point are (from
> -s 32 bit/single
> -l 64 bit/double
> -t 80 bit/extended
Thank you this is useful!
> I will write a bug report.
Thank you for writing that bug report.
I finally got the plain pascal version to work properly! My major
problem was I accidentally used the sqr function instead of sqrt. Here's
the final product:
LogBase : Double;
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
exOverflow, exUnderflow, exPrecision]);
for i := DataSize-1 downto 0 do
Tmp := sqrt(sqr(InData[i].Im) + sqr(InData[i].Re));
if Tmp > 0.0 then
Tmp := (ln(Tmp)/ln(2))*LogBase+Shift
Tmp := 0.0;
OutData[i] := Tmp;
In case anyone is interested, this generates 45 lines of assembly. The
handwritten asm code is 40 lines. (not including the procedure pre and
post asm for either method) I cheated a little and copied the log2 code
directly to avoid the function calls, this resulted in the compiler
doing the math ahead of time.
More information about the fpc-pascal