xref: /csrg-svn/lib/libc/vax/gen/_setjmp.s (revision 22289)
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved.  The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
8	.asciz	"@(#)_setjmp.s	5.2 (Berkeley) 06/05/85"
9#endif not lint
10
11
12/*
13 * C library -- _setjmp, _longjmp
14 *
15 *	_longjmp(a,v)
16 * will generate a "return(v)" from
17 * the last call to
18 *	_setjmp(a)
19 * by restoring registers from the stack,
20 * The previous signal state is NOT restored.
21 */
22
23#include "DEFS.h"
24
25ENTRY(_setjmp, 0)
26	movl	4(ap),r0
27	movl	12(fp),(r0)		# save frame pointer of caller
28	movl	16(fp),4(r0)		# save pc of caller
29	clrl	r0
30	ret
31
32ENTRY(_longjmp, 0)
33	movl	8(ap),r0		# return(v)
34	movl	4(ap),r1		# fetch buffer
35	tstl	(r1)
36	beql	botch
37loop:
38	bitw	$1,6(fp)		# r0 saved?
39	beql	1f
40	movl	r0,20(fp)
41	bitw	$2,6(fp)		# was r1 saved?
42	beql	2f
43	movl	r1,24(fp)
44	brb	2f
451:
46	bitw	$2,6(fp)		# was r1 saved?
47	beql	2f
48	movl	r1,20(fp)
492:
50	cmpl	(r1),12(fp)
51	beql	done
52	blssu	botch
53	movl	$loop,16(fp)
54	ret				# pop another frame
55
56done:
57	cmpb	*16(fp),reiins		# returning to an "rei"?
58	bneq	1f
59	movab	3f,16(fp)		# do return w/ psl-pc pop
60	brw	2f
611:
62	movab	4f,16(fp)		# do standard return
632:
64	ret				# unwind stack before signals enabled
653:
66	addl2	$8,sp			# compensate for PSL-PC push
674:
68	jmp	*4(r1)			# done, return....
69
70botch:
71	pushl	$msgend-msg
72	pushl	$msg
73	pushl	$2
74	calls	$3,_write
75	halt
76
77	.data
78msg:	.ascii	"_longjmp botch\n"
79msgend:
80reiins:	rei
81