2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Call the entry point of a BCPL style routine
9 /*****************************************************************************
13 AROS_UFH7(ULONG, AOS_CallEntry,
16 AROS_UFHA(STRPTR, argptr, A0),
17 AROS_UFHA(ULONG, argsize, D0),
18 AROS_UFHA(LONG_FUNC, entry, A4),
19 AROS_UFHA(BPTR, startpkt, D1),
20 AROS_UFHA(APTR, globvec, A2),
21 AROS_UFHA(APTR, splower, A1),
22 AROS_UFHA(APTR, returnaddr, A3)
31 argptr - Argument pointer (advisory)
32 Non-NULL for CLI, NULL for Workbench
33 argsize - Length of arguments (for CLI only)
34 entry - Routine to call
35 startpkt - BPTR to startup packet (for CLI only)
36 globvec - DOS global vector (for CLI only)
37 splower - Bottom of the stack
40 Return value from calling entry()
53 ******************************************************************************/
55 #include "aros/m68k/asm.h"
65 * A0 - Argptr (NULL for WB, non-NULL for CLI)
77 movem.l %d2-%d7/%a2-%a6,%sp@-
81 /* Make sure me->pr_ReturnAddr is correct */
83 neg.l %d7 /* D7 = - tc_SPLower */
84 lea.l %sp@(%d7),%a5 /* A5 = %sp - tc_SPLower */
85 move.l %a5,%sp@- /* sp+ 4 = stksize */
86 move.l %sp,%a3@ /* Save address of return address */
88 /* If %a0 is set, it's a CLI app */
98 /* Some programs assume A3 = seglist */
106 move.l %a4,%sp@- /* Put the address to call on the stack */
108 move.l %d7,%a0 /* Clear registers */
109 move.l %d7,%a1 /* Clear registers */
115 rts /* Pop and 'return' to the entry point */
119 addq.l #4,%sp /* Drop the stacksize off the stack */
120 movem.l %sp@+,%d2-%d7/%a2-%a6
123 /* Helper function used by BCPL_RunHandler
127 movem.l %d2-%d7/%a2-%a6,%sp@-
128 /* Make sure me->pr_ReturnAddr is correct */
130 neg.l %d7 /* D7 = - tc_SPLower */
131 lea.l %sp@(%d7),%a5 /* A5 = %sp - tc_SPLower */
132 move.l %a5,%sp@- /* sp+ 4 = stksize */
133 move.l %sp,%a3@ /* Save address of return address */
138 /* Skip past the 3 words we need for the BCPL_jsr */
140 pea.l 0f /* sp = return address */
141 jsr %a5@ /* The BCPL_jsr will pop the stack ! */
142 addq.l #4,%sp /* Drop the return location */
143 0: /* BCPL Exit arrives here */
144 addq.l #4,%sp /* Drop the stacksize off */
145 movem.l %sp@+,%d2-%d7/%a2-%a6
146 move.l %d1,%d0 /* Duplicate D1 */