i386-elf-20030623
[openafs.git] / src / lwp / process.i386.s
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* Sun 386i... I hope this does the right thing!!!
11  * 
12  * Written by Derek Atkins <warlord@MIT.EDU>
13  * (debugging help by Chris Provenzano <proven@mit.edu>)
14  * 11/1991
15  *
16  * "ojala que es correcto!"
17  */
18
19 #define IGNORE_STDS_H   1
20 /*#ifndef AFS_DJGPP_ENV*/
21 #include <afs/param.h>
22 /*#endif /* AFS_DJGPP_ENV */
23
24         .file "process.s"
25
26         .data
27
28         .text
29
30 /*
31  * struct savearea {
32  *      char    *topstack;
33  * }
34  */
35
36         .set    topstack,0
37
38 /*
39  * savecontext(f, area1, newsp)
40  *      int (*f)(); struct savearea *area1; char *newsp;
41  */
42
43 /* offsets, to make my life easier! */
44         .set    f,8
45         .set    area1,12
46         .set    newsp,16
47
48
49 #if defined(AFS_DJGPP_ENV) || (defined(AFS_OBSD_ENV) && !defined (AFS_OBSD34_ENV))
50 #define PRE_Block       _PRE_Block
51 #define savecontext     _savecontext
52 #define abort           _abort
53 #define returnto        _returnto
54 #endif /* AFS_DJGPP_ENV */
55
56 .globl  PRE_Block
57 .globl  savecontext
58
59         savecontext:
60         pushl   %ebp                    /* New Frame! */
61         movl    %esp,%ebp
62         pusha                           /* Push all registers */
63         movl    $1,PRE_Block            /* Pre-emption code */
64         movl    area1(%ebp),%eax        /* eax = base of savearea */
65         movl    %esp,(%eax)             /* area->topstack = esp */
66         movl    newsp(%ebp),%eax        /* get new sp into eax */
67         cmpl    $0,%eax
68         je      L1                      /* if new sp is 0 then dont change esp */
69         movl    %eax,%esp               /* go ahead.  make my day! */
70 L1:
71         jmp     *f(%ebp)                        /* ebx = &f */
72
73 /* Shouldnt be here....*/
74
75         call    abort
76
77 /*
78  * returnto(area2)
79  *      struct savearea *area2;
80  */
81
82 /* stack offset */
83         .set    area2,8
84
85 .globl  returnto
86
87 returnto:
88         pushl   %ebp
89         movl    %esp, %ebp              /* New frame, to get correct pointer */
90         movl    area2(%ebp),%eax        /* eax = area2 */
91         movl    (%eax),%esp             /* restore esp */
92         popa 
93         movl    $0,PRE_Block            /* clear it up... */
94         popl    %ebp
95         ret
96
97 /* I see, said the blind man, as he picked up his hammer and saw! */
98         pushl   $1234
99         call    abort