[fpc-pascal] Converting 32bit intel asm to Pascal or 64bit at&t asm
Thomas Schatzl
tom_at_work at gmx.at
Wed Mar 9 20:18:01 CET 2011
On Wed, 09 Mar 2011 13:23:55 -0500, Andrew Haines wrote:
> On 03/09/11 12:26, Thomas Schatzl wrote:
>> Hi,
>>
>> On Wed, 09 Mar 2011 11:58:08 -0500, Andrew Haines wrote:
>>> if Tmp <> Im then
>>> begin
>>> //Tmp := ln(Tmp)*LogBase+Shift; // same as the following
>>> asm
>>> proc?
>>> asm
>>> FLD LogBase;
>>> FLD Tmp;
>>> FYL2X;
>>
>> FYL2X calculates the log to the base 2 of tmp, not log to the base e
>> of
>> tmp? Just a guess.
>>
>> Thomas
>>
>
> 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.
>
> The current output with the pascal code looks like it did when FLDS
> was
> used instead of FLDL to load (%rdi). The intel code was "FLD
> QWORD[EDI]"
> I changed this to "FLDQ (%edi)". on x32 it became FLDL and on x64 it
> became FLDS. changing the line to "FLDL (%rdi)" on x86_64 fixed the
> last
> problem I had with the asm translation.
Suffixes for gas for floating point are (from
http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax)
-s 32 bit/single
-l 64 bit/double
-t 80 bit/extended
With Intel syntax you can only hope that the compiler guesses
correctly, or add an explicit override.
So you suggest that the assembler changes an inlined "fldq (%edi)" into
"flds (%edi)" on x86-64? This looks like a bug if true - it should
reject the "q" suffix for floating point operations.
At least gas 2.19 on solaris x64 rejects "fldq"; actually the 2.4.2
release compiler transforms "fldq" into "fld" here, which gas rejects
too :)
I will write a bug report.
Thomas
More information about the fpc-pascal
mailing list