64 bit inline assembly in Delphi XE3

I ran into this issue using 64-bit inline assembler in Delphi XE3 that I don't understand.

I tried this, and it works on both 32-bit and 64-bit

function test(a, b: integer): integer; assembler; register;
asm
  mov eax, a
  add eax, edx
end;

However, this only works on 32-bit but not 64-bit, in 64-bit it compiles, but did not return correct result of the sum of two integers.

function test(a, b: integer): integer; assembler; register;
asm
  add eax, edx
end;

I know previous FPU code such as FLD, STP works on 32-bit but it will give compilation error on 64-bit compiler. Any idea how to handle floating numbers in 64-bit ?


It is because 64-bit system uses own calling convention, and these parameters are in RCX and RDX registers. More explanations in MSDN.

About handling floating numbers - read Intel developer documentation.

链接地址: http://www.djcxy.com/p/72732.html

上一篇: x86上的SSE,堆栈对齐

下一篇: Delphi XE3中的64位内联汇编