dont try to convert the pixfmt while calculating the "shade"
[AROS.git] / arch / m68k-all / exec / stackswap.S
blob5764e25d1db6ab843c1167b54687940658149e25
1 /*
2     Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3     $Id$
4 */
6 /*****************************************************************************
7  
8     NAME
9  
10         AROS_LH1(void, StackSwap,
12     SYNOPSIS
13         AROS_LHA(struct StackSwapStruct *, newStack, A0),
15     LOCATION
16         struct ExecBase *, SysBase, 122, Exec)
18     FUNCTION
19         This function switches to the new stack given by the parameters in the
20         stackswapstruct structure. The old stack parameters are returned in
21         the same structure so that the stack can be restored later
23     INPUTS
24         newStack - parameters for the new stack
26     RESULT
28     NOTES
30     EXAMPLE
32     BUGS
34     SEE ALSO
36     INTERNALS
38     HISTORY
40 ******************************************************************************/
42         #include "aros/m68k/asm.h"
44         .text
45         .balign 4
46         .globl  AROS_SLIB_ENTRY(StackSwap,Exec,122)
48 AROS_SLIB_ENTRY(StackSwap,Exec,122):
50         // Here's how the stack looks right now
51         // 0(%sp) : Return Address
53         /* Preserve returnaddress and fix sp */
54         move.l  (%sp)+,%d1       // d1 contains return address
55                                  // now the stack is 'clean'
57         move.l  %a6,%sp@-       // save contents of %a6
59         /* Get pointer to tc_SPLower in a1 (tc_SPUpper is next) */
60         move.l  0x4,%a6          // execbase to a6
61         move.l  %a6@(ThisTask),%a1
63         move.l  %d1,%d0          // d0 contains return address now
66         movem.l %d0/%a0/%a1,%sp@- // d0: save return address on stack
67                                    // a0: param to this function onto stack
68                                    // a1: address of task to stack
69         /* Just to be sure interrupts always find a good stackframe */
70         jsr     Disable(%a6)       // disable interrupts
71         movem.l %sp@+,%d0/%a0/%a1  // a1 holds address of task
72                                     // a0 holds param to this function
73                                     // d0 holds return address
74         
75         move.l  (%sp)+,%a6       // original a6 from stack
77         /* Swap Lower boundaries */
78         move.l  %a1@(tc_SPLower),%d1        // d1 holds content of tc_SPLower
79         move.l  %a0@,%a1@(tc_SPLower)       // write the content of the first param in
80                                             // the structure to this function to tc_SPLower
81         move.l  %d1,%a0@+                   // write old tc_SPLower to StackSwap
83         /* Swap higher boundaries */
84         move.l  %a1@(tc_SPUpper),%d1        // d1 holds content of tc_SPUpper
85         move.l  %a0@,%a1@(tc_SPUpper)       // write the content of the 2nd param in
86                                             // the structure to this function to tc_SPUpper
87         move.l  %d1,%a0@+                   // write old tc_SPUpper to StackSwap
89         /* Swap stackpointers */
90         move.l  %sp,%d1                     // current stack pointer to d1
91         move.l  %a0@,%sp                    // desired stack pointer to sp
92         move.l  %d1,%a0@                    // old stack pointer back into the structure
94         movem.l %d0/%a6,%sp@-               // save %d0 onto stack
95                                             // save %a6 onto stack
96         
97         /* Reenable interrupts. */
98         move.l  0x4,%a6                     // get ExecBase
99         jsr     Enable(%a6)                 // Enable interrupts
100         movem.l %sp@+,%d0/%a6       // restore orig. content of %a6 register
101                                      // restore return address to d0
102         /* Restore returnaddress and return */
103         move.l  %d0,%sp@-       // return address onto stack 
105         // Here's how the stack looks right now
106         // 0(%sp) : Return Address
107         // 4(%sp) : fake pointer to StackSwap structure
108         rts