install approved copyright notice
[unix-history] / usr / src / lib / libc / vax / gen / _setjmp.s
CommitLineData
586c39b1
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
493b70ca
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
f4f66d2c
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
586c39b1
DF
16 */
17
f4f66d2c
KB
18#if defined(LIBC_SCCS) && !defined(lint)
19 .asciz "@(#)_setjmp.s 5.7 (Berkeley) %G%"
20#endif /* LIBC_SCCS and not lint */
a768153c
SL
21
22/*
23 * C library -- _setjmp, _longjmp
24 *
25 * _longjmp(a,v)
26 * will generate a "return(v)" from
27 * the last call to
28 * _setjmp(a)
29 * by restoring registers from the stack,
30 * The previous signal state is NOT restored.
31 */
32
33#include "DEFS.h"
34
dadab5a2 35ENTRY(_setjmp, 0)
a768153c
SL
36 movl 4(ap),r0
37 movl 12(fp),(r0) # save frame pointer of caller
38 movl 16(fp),4(r0) # save pc of caller
39 clrl r0
40 ret
41
dadab5a2 42ENTRY(_longjmp, 0)
a768153c
SL
43 movl 8(ap),r0 # return(v)
44 movl 4(ap),r1 # fetch buffer
45 tstl (r1)
46 beql botch
47loop:
48 bitw $1,6(fp) # r0 saved?
49 beql 1f
50 movl r0,20(fp)
51 bitw $2,6(fp) # was r1 saved?
52 beql 2f
53 movl r1,24(fp)
54 brb 2f
551:
56 bitw $2,6(fp) # was r1 saved?
57 beql 2f
58 movl r1,20(fp)
592:
60 cmpl (r1),12(fp)
61 beql done
62 blssu botch
63 movl $loop,16(fp)
64 ret # pop another frame
65
66done:
67 cmpb *16(fp),reiins # returning to an "rei"?
68 bneq 1f
69 movab 3f,16(fp) # do return w/ psl-pc pop
70 brw 2f
711:
72 movab 4f,16(fp) # do standard return
732:
74 ret # unwind stack before signals enabled
753:
76 addl2 $8,sp # compensate for PSL-PC push
774:
78 jmp *4(r1) # done, return....
79
80botch:
f6a3ad26 81 calls $0,_longjmperror
a768153c 82 halt
687624f7
MK
83
84 .data
85reiins: rei