Browse Source

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 -
Károly Balogh 8 years ago
parent
commit
f31cefd240
1 changed files with 18 additions and 3 deletions
  1. 18 3
      packages/amunits/src/coreunits/amigalib.pas

+ 18 - 3
packages/amunits/src/coreunits/amigalib.pas

@@ -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;