Register Calling Convention
Ojbect Pascal的默认调用约定为register,寄存器调用约定会将前三个参数依次放入eax,edx,ecx,返回值是eax(根据类型不同有差别).
function Add3Int(i,j,k:integer): integer;
//i,j,k依次放入eax,edx,ecx
asm
add eax,edx
add eax,ecx
end; procedure TForm1.btnTestPureAsmClick(Sender: TObject);
begin
ShowMessageFmt('i=%d',[Add3Int(1,2,3)]); //结果为6
end;
How Values Are Returned from Delphi Functions.
Return Type Return Method
Char, Byte al register.
SmallInt, Word ax register.
Integer, LongWord, AnsiString, Pointer, class eax register.
Real48 eax contains a pointer to data on the stack.
Int64 edx:eax register pair.
Single, Double, Extended, Comp ST(0) on 8087’s register stack.