4 ****************************************************************************
5 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
7 * Permission to use, copy, modify, and distribute this software and its *
8 * documentation for any purpose and without fee is hereby granted, *
9 * provided that the above copyright notice appear in all copies and *
10 * that both that copyright notice and this permission notice appear in *
11 * supporting documentation, and that the name of IBM not be used in *
12 * advertising or publicity pertaining to distribution of the software *
13 * without specific, written prior permission. *
15 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
19 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
20 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
21 ****************************************************************************
32 # Information Technology Center
33 # Carnegie-Mellon University
41 # Transcribed for Vaxen by M. Satyanarayanan, September 1985
42 # Algorithm: "Monkey see, monkey do"
58 /* Stuff to allow saving/restoring registers */
61 # savecontext(f, area1, newsp)
62 # int (*f)(); struct savearea *area1; char *newsp;
65 /* Stack offsets of arguments */
70 .globl _C_LABEL(PRE_Block)
71 .globl _C_LABEL(savecontext)
74 .word 0x0ffc # Save regs R2-R11
75 movl $1,_C_LABEL(PRE_Block) # Critical section for preemption code
76 pushl %ap # save old ap
77 pushl %fp # save old fp
78 movl area1(%ap),%r0 # r0 = base of savearea
79 movl %sp,topstack(%r0) # area->topstack = sp
80 movl newsp(%ap),%r0 # Get new sp
81 beql L1 # if new sp is 0, dont change stacks
82 movl %r0,%sp # else switch to new stack
84 movl f(%ap),%r1 # r1 = f
87 /* It is impossible to be here, so abort() */
89 calls $0,_C_LABEL(abort)
93 # struct savearea *area2;
96 /* Stack offset of argument */
99 .globl _C_LABEL(returnto)
101 .word 0x0 # Who cares about these regs?
102 movl area2(%ap),%r0 # r0 = address of area2
103 movl topstack(%r0),%sp # Restore sp
104 movl (%sp)+,%fp # Restore fp
105 movl (%sp)+,%ap # ,,,,
106 clrl _C_LABEL(PRE_Block) # End of preemption critical section
109 pushl $1234 # I will gloat, Kazar
110 calls $0,_C_LABEL(abort)