xref: /original-bsd/lib/libc/vax/gen/_setjmp.s (revision 1aa52444)
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
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.
16 */
17
18#if defined(LIBC_SCCS) && !defined(lint)
19	.asciz "@(#)_setjmp.s	5.7 (Berkeley) 06/27/88"
20#endif /* LIBC_SCCS and not lint */
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
35ENTRY(_setjmp, 0)
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
42ENTRY(_longjmp, 0)
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:
81	calls	$0,_longjmperror
82	halt
83
84	.data
85reiins: rei
86