amunits: new HookEntryPas function, to support hooks using the Register calling convention. It is actually advised to use cdecl functions instead.

git-svn-id: trunk@34829 -
This commit is contained in:
Károly Balogh 2016-11-06 23:32:19 +00:00
parent 38837ee973
commit f31cefd240

View File

@ -399,9 +399,9 @@ end;
{ Do *NOT* change this to nostackframe! }
{ The compiler will build a stackframe with link/unlk. So that will actually correct
the stackpointer for both Pascal/StdCall and cdecl functions, so the stackpointer will
be correct on exit. It also needs no manual RTS. The argument push order is also
correct for both. (KB) }
the stackpointer for both Pascal/StdCall and Cdecl functions, so the stackpointer
will be correct on exit. It also needs no manual RTS. The argument push order is
also correct for both. (KB) }
procedure HookEntry; assembler;
asm
move.l a1,-(a7) // Msg
@ -411,6 +411,21 @@ asm
jsr (a0) // Call the SubEntry
end;
{ This is to be used with when the subentry function uses FPC's register calling
convention, also see the comments above HookEntry. It is advised to actually
declare Hook functions with cdecl instead of using this function, especially
when writing code which is platform independent. (KB) }
procedure HookEntryPas; assembler;
asm
move.l a2,-(a7)
move.l a1,-(a7) // Msg
move.l a2,a1 // Obj
// PHook is in a0 already
move.l 12(a0),a2 // h_SubEntry = Offset 12
jsr (a2) // Call the SubEntry
move.l (a7)+,a2
end;
procedure printf(Fmtstr : pchar; const Args : array of const);
var
i,j : longint;