dont try to convert the pixfmt while calculating the "shade"
[AROS.git] / arch / m68k-all / exec / newstackswap.S
blobb0f906298aed142e7bdbc3aa425bff33429b2f96
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_LH3(IPTR, NewStackSwap,
16     SYNOPSIS
17         AROS_LHA(struct StackSwapStruct *,  sss, A0),
18         AROS_LHA(LONG_FUNC, entry, A1),
19         AROS_LHA(struct StackSwapArgs *, args, A2),
21     LOCATION
22         struct ExecBase *, SysBase, 134, Exec)
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  AROS_SLIB_ENTRY(NewStackSwap,Exec,134)
58 AROS_SLIB_ENTRY(NewStackSwap,Exec,134):
59     /* Stackswap will clobber %d0, %d1, %a0, and %a1,
60      * so we need to save %a0/%a1 in %a3/%a4
61      */
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
87      */
88     movem.l     %sp@+,%a3/%a4
89     rts