可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have a little problem with FLD instruction in x64 bit ... want to load Double value to the stack pointer FPU in st0 register, but it seem to be impossible. In Delphi x32, I can use this code :
function DoSomething(X:Double):Double; asm FLD X // Do Something .. FST Result end;
Unfortunately, in x64, the same code does not work.
回答1:
In x64 mode floating point parameters are passed in xmm-registers. So when Delphi tries to compile FLD X, it becomes FLD xmm0 but there is no such instruction. You first need to move it to memory.
The same goes with the result, it should be passed back in xmm0.
Try this (not tested):
function DoSomething(X:Double):Double; var Temp : double; asm MOVQ qword ptr Temp,X FLD Temp //do something FST Temp MOVQ xmm0,qword ptr Temp end;
回答2:
Delphi inherite Microsoft x64 Calling Convention. So if arguments of function/procedure are float/double, they are passed in XMM0L, XMM1L, XMM2L, and XMM3L registers.
But you can use var
before parameter as workaround like:
function DoSomething(var X:Double):Double; asm FLD qword ptr [X] // Do Something .. FST Result end;