Delphi only supports Intel-style assembly. I.e., Intel-style assembly in FPC should behave the same as the assembly in Delphi.Okay, I take Your word .. ;-)
Switching back to {$mode objfpc}{$H+} I get ..In objfpc mode you need to add the keyword (http://www.freepascal.org/docs-html/ref/refse95.html#x186-20800014.9) assembler:
.. Fatal: Syntax error, "BEGIN" expected but "ASM" found
Is there no way to make it compile with {$mode objfpc}{$H+} ?
I would like to leave behind the Delphi 5 version ..
Is there no way to make it compile with {$mode objfpc}{$H+} ?
I would like to leave behind the Delphi 5 version ..
.. you can perfectly keep compiling your code using {$mode delphi} in FPC. We don't plan on removing this mode, nor on changing it so that it will break your code.
In objfpc mode you need to add the keyword (http://www.freepascal.org/docs-html/ref/refse95.html#x186-20800014.9) assemblerThanks for this hint !
fpc}
{$mode delphi}
{$endif}
function LogN( Base, X: Extended): Extended;
assembler;
asm
FLD1
FLD X
FYL2X
FLD1
FLD Base
FYL2X
FDIV // Lazarus Warning: fdivrp without operand translated into fdivrpP
FWAIT
end;
begin
writeln(logn(2,10));
end.
$ dcc tt3.pp
Borland Delphi for Linux Version 14.5
Copyright (c) 1983,2002 Borland Software Corporation
tt3.pp(22)
23 lines, 0.01 seconds, 23412 bytes code, 3132 bytes data.
$ ./tt3
3.32192809488736E+0000
$ ppn69 ./tt3.pp
Free Pascal Compiler version 3.1.1 [2016/07/19] for i386
Copyright (c) 1993-2016 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling ./tt3.pp
tt3.pp(14,9) Warning: fdivrp without operand translated into fdivrpP
tt3.pp(14,9) Warning: "fdivrp" without operand translated into "fdivrp %st,%st(1)"
Linking tt3
21 lines compiled, 0.2 sec
2 warning(s) issued
$ ./tt3
3.32192809488736234781E+0000
Note this guidance also means that the other way around is hardly possible: compile fpc code that contains proper FDIV into Delphi ....would lead to floating point stack corruption.I have replaced the FDIV with FDIVP.
But in this case, changing Delphi sourcecode FDIV's to FDIVP's will solve it.
I gambled that AT&T->intel required an inversion of arguments, but my copro asm is not really 100%.Yes, seems to be AT&T synthax.