int To_Asm_Fnc(dword Amem, dword Al, dword Ac) {
int b = 0;
asm ("push %%ecx; \
call %%eax; \
pop %%ecx;"
: "=Al" (b) /* output value */
: "Al" (mem), "Ac" (Al), "d" (Ac) /* input value */
);
return b;
}
这是我的delphi尝试
Function To_Asm_Fnc(Amem,Al,Ac:dword):Integer;
var
b:Integer;
begin
Result:=0;
b:=0;
//*******
{ i really didn't get it as in the c++ code }
//*******
Result:=b;
end;
非常感谢
答案 0 :(得分:6)
似乎此函数接受指向另一个函数的指针并设置参数
function To_Asm_Fnc(Amem: Pointer; _Al, _Ac: cardinal): integer;
asm
// x68 only!; paramateres are passed differently in x64
// inputs : "Al" (mem), "Ac" (Al), "d" (Ac) /* input value */
// amem is already in eax
// _al is passed in edx and _ac in ecx; but the code expects them reversed
xchg edx, ecx
push ecx
call eax
pop ecx
// result is already in eax and delphi returns the result in eax
// outputs : "=Al" (b) /* output value */
end;