xref: /csrg-svn/lib/libc/vax/gen/_setjmp.s (revision 34819)
121418Sdist/*
221418Sdist * Copyright (c) 1980 Regents of the University of California.
334480Sbostic * All rights reserved.
434480Sbostic *
534480Sbostic * Redistribution and use in source and binary forms are permitted
6*34819Sbostic * provided that the above copyright notice and this paragraph are
7*34819Sbostic * duplicated in all such forms and that any documentation,
8*34819Sbostic * advertising materials, and other materials related to such
9*34819Sbostic * distribution and use acknowledge that the software was developed
10*34819Sbostic * by the University of California, Berkeley.  The name of the
11*34819Sbostic * University may not be used to endorse or promote products derived
12*34819Sbostic * from this software without specific prior written permission.
13*34819Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34819Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34819Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1621418Sdist */
1713498Ssam
18*34819Sbostic#if defined(LIBC_SCCS) && !defined(lint)
19*34819Sbostic	.asciz "@(#)_setjmp.s	5.7 (Berkeley) 06/27/88"
20*34819Sbostic#endif /* LIBC_SCCS and not lint */
2121418Sdist
2213498Ssam/*
2313498Ssam * C library -- _setjmp, _longjmp
2413498Ssam *
2513498Ssam *	_longjmp(a,v)
2613498Ssam * will generate a "return(v)" from
2713498Ssam * the last call to
2813498Ssam *	_setjmp(a)
2913498Ssam * by restoring registers from the stack,
3013498Ssam * The previous signal state is NOT restored.
3113498Ssam */
3213498Ssam
3313498Ssam#include "DEFS.h"
3413498Ssam
3517328SsamENTRY(_setjmp, 0)
3613498Ssam	movl	4(ap),r0
3713498Ssam	movl	12(fp),(r0)		# save frame pointer of caller
3813498Ssam	movl	16(fp),4(r0)		# save pc of caller
3913498Ssam	clrl	r0
4013498Ssam	ret
4113498Ssam
4217328SsamENTRY(_longjmp, 0)
4313498Ssam	movl	8(ap),r0		# return(v)
4413498Ssam	movl	4(ap),r1		# fetch buffer
4513498Ssam	tstl	(r1)
4613498Ssam	beql	botch
4713498Ssamloop:
4813498Ssam	bitw	$1,6(fp)		# r0 saved?
4913498Ssam	beql	1f
5013498Ssam	movl	r0,20(fp)
5113498Ssam	bitw	$2,6(fp)		# was r1 saved?
5213498Ssam	beql	2f
5313498Ssam	movl	r1,24(fp)
5413498Ssam	brb	2f
5513498Ssam1:
5613498Ssam	bitw	$2,6(fp)		# was r1 saved?
5713498Ssam	beql	2f
5813498Ssam	movl	r1,20(fp)
5913498Ssam2:
6013498Ssam	cmpl	(r1),12(fp)
6113498Ssam	beql	done
6213498Ssam	blssu	botch
6313498Ssam	movl	$loop,16(fp)
6413498Ssam	ret				# pop another frame
6513498Ssam
6613498Ssamdone:
6713498Ssam	cmpb	*16(fp),reiins		# returning to an "rei"?
6813498Ssam	bneq	1f
6913498Ssam	movab	3f,16(fp)		# do return w/ psl-pc pop
7013498Ssam	brw	2f
7113498Ssam1:
7213498Ssam	movab	4f,16(fp)		# do standard return
7313498Ssam2:
7413498Ssam	ret				# unwind stack before signals enabled
7513498Ssam3:
7613498Ssam	addl2	$8,sp			# compensate for PSL-PC push
7713498Ssam4:
7813498Ssam	jmp	*4(r1)			# done, return....
7913498Ssam
8013498Ssambotch:
8125784Smckusick	calls	$0,_longjmperror
8213498Ssam	halt
8325922Skarels
8425922Skarels	.data
8525922Skarelsreiins: rei
86