xref: /original-bsd/lib/libc/hp300/gen/_setjmp.s (revision c3e32dec)
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * the Systems Programming Group of the University of Utah Computer
7 * Science Department.
8 *
9 * %sccs.include.redist.c%
10 */
11
12#if defined(LIBC_SCCS) && !defined(lint)
13	.asciz "@(#)_setjmp.s	8.1 (Berkeley) 06/04/93"
14#endif /* LIBC_SCCS and not lint */
15
16/*
17 * C library -- _setjmp, _longjmp
18 *
19 *	_longjmp(a,v)
20 * will generate a "return(v)" from
21 * the last call to
22 *	_setjmp(a)
23 * by restoring registers from the stack,
24 * The previous signal state is NOT restored.
25 */
26
27#include "DEFS.h"
28
29ENTRY(_setjmp)
30	movl	sp@(4),a0	/* save area pointer */
31	clrl	a0@+		/* no old onstack */
32	clrl	a0@+		/* no old sigmask */
33	movl	sp,a0@+		/* save old SP */
34	movl	a6,a0@+		/* save old FP */
35	clrl	a0@+		/* no old AP */
36	movl	sp@,a0@+	/* save old PC */
37	clrl	a0@+		/* clear PS */
38	moveml	#0x3CFC,a0@	/* save other non-scratch regs */
39	clrl	d0		/* return zero */
40	rts
41
42ENTRY(_longjmp)
43	movl	sp@(4),a0	/* save area pointer */
44	addql	#8,a0		/* skip onstack/sigmask */
45	tstl	a0@		/* ensure non-zero SP */
46	jeq	botch		/* oops! */
47	movl	sp@(8),d0	/* grab return value */
48	jne	ok		/* non-zero ok */
49	moveq	#1,d0		/* else make non-zero */
50ok:
51	movl	a0@+,sp		/* restore SP */
52	movl	a0@+,a6		/* restore FP */
53	addql	#4,a0		/* skip AP */
54	movl	a0@+,sp@	/* restore PC */
55	moveml	a0@(4),#0x3CFC	/* restore non-scratch regs */
56	rts
57
58botch:
59	jsr	_longjmperror
60	stop	#0
61