lcms2.library: fixed strict aliasing issue detected with gcc 4.8.3
[AROS.git] / arch / m68k-amiga / c / newstackswap.s
blob0d86412b06a23fe635430dcb9d89f2b9da3e6b08
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: NewStackSwap() - Call a function with swapped stack.
6 Lang: english
7 */
8 /*****************************************************************************
10 NAME
11 #include <exec/tasks.h>
12 #include <proto/exec.h>
14 AROS_UFH4(IPTR, myNewStackSwap,
16 SYNOPSIS
17 AROS_UFHA(struct StackSwapStruct *, sss, A0),
18 AROS_UFHA(LONG_FUNC, entry, A1),
19 AROS_UFHA(struct StackSwapArgs *, args, A2),
20 AROS_UFHA(struct ExecBase *, SysBase, A6))
22 LOCATION
24 FUNCTION
25 Calls a function with a new stack.
27 INPUTS
28 sss - A structure containing the values for the upper, lower
29 and current bounds of the stack you wish to use.
30 entry - Address of the function to call.
31 args - A structure (actually an array) containing up to 8
32 function arguments. The function is called using C calling
33 convention (no AROS_UHFx macro needed).
35 RESULT
36 A value actually returned by your function. The function will be
37 running on a new stack.
39 NOTES
41 EXAMPLE
43 BUGS
44 Do not attempt to pass in a prebuilt stack - it will be erased.
46 SEE ALSO
47 StackSwap()
49 INTERNALS
50 This function is be replaced in $(ARCH).
52 ******************************************************************************/
53 #include "aros/m68k/asm.h"
55 .text
56 .balign 4
57 .globl myNewStackSwap
58 myNewStackSwap:
59 /* Stackswap will clobber %d0, %d1, %a0, and %a1,
60 * so we need to save %a0/%a1 in %a3/%a4
62 movem.l %a3/%a4,%sp@-
63 move.l %a0,%a3
64 move.l %a1,%a4
66 jsr %a6@(StackSwap)
68 move.l %a2@(7*4),%sp@- // Put the C arguments on the stack
69 move.l %a2@(6*4),%sp@-
70 move.l %a2@(5*4),%sp@-
71 move.l %a2@(4*4),%sp@-
72 move.l %a2@(3*4),%sp@-
73 move.l %a2@(2*4),%sp@-
74 move.l %a2@(1*4),%sp@-
75 move.l %a2@(0*4),%sp@-
77 jsr %a4@ // Call the C function
79 lea.l %sp@(8*4),%sp // Remove the C arguments
81 move.l %d0,%a4 // save C function returncode
82 move.l %a3,%a0
83 jsr %a6@(StackSwap)
84 move.l %a4,%d0
86 /* Now we can restore %a3/%a4
88 movem.l %sp@+,%a3/%a4
89 rts