xref: /csrg-svn/lib/libc/vax/gen/_setjmp.s (revision 34480)
121418Sdist/*
221418Sdist * Copyright (c) 1980 Regents of the University of California.
3*34480Sbostic * All rights reserved.
4*34480Sbostic *
5*34480Sbostic * Redistribution and use in source and binary forms are permitted
6*34480Sbostic * provided that this notice is preserved and that due credit is given
7*34480Sbostic * to the University of California at Berkeley. The name of the University
8*34480Sbostic * may not be used to endorse or promote products derived from this
9*34480Sbostic * software without specific written prior permission. This software
10*34480Sbostic * is provided ``as is'' without express or implied warranty.
1121418Sdist */
1213498Ssam
13*34480Sbostic#if defined(SYSLIBC_SCCS) && !defined(lint)
14*34480Sbostic_sccsid:.asciz	"@(#)_setjmp.s	5.6 (Berkeley) 05/25/88"
15*34480Sbostic#endif /* SYSLIBC_SCCS and not lint */
1621418Sdist
1713498Ssam/*
1813498Ssam * C library -- _setjmp, _longjmp
1913498Ssam *
2013498Ssam *	_longjmp(a,v)
2113498Ssam * will generate a "return(v)" from
2213498Ssam * the last call to
2313498Ssam *	_setjmp(a)
2413498Ssam * by restoring registers from the stack,
2513498Ssam * The previous signal state is NOT restored.
2613498Ssam */
2713498Ssam
2813498Ssam#include "DEFS.h"
2913498Ssam
3017328SsamENTRY(_setjmp, 0)
3113498Ssam	movl	4(ap),r0
3213498Ssam	movl	12(fp),(r0)		# save frame pointer of caller
3313498Ssam	movl	16(fp),4(r0)		# save pc of caller
3413498Ssam	clrl	r0
3513498Ssam	ret
3613498Ssam
3717328SsamENTRY(_longjmp, 0)
3813498Ssam	movl	8(ap),r0		# return(v)
3913498Ssam	movl	4(ap),r1		# fetch buffer
4013498Ssam	tstl	(r1)
4113498Ssam	beql	botch
4213498Ssamloop:
4313498Ssam	bitw	$1,6(fp)		# r0 saved?
4413498Ssam	beql	1f
4513498Ssam	movl	r0,20(fp)
4613498Ssam	bitw	$2,6(fp)		# was r1 saved?
4713498Ssam	beql	2f
4813498Ssam	movl	r1,24(fp)
4913498Ssam	brb	2f
5013498Ssam1:
5113498Ssam	bitw	$2,6(fp)		# was r1 saved?
5213498Ssam	beql	2f
5313498Ssam	movl	r1,20(fp)
5413498Ssam2:
5513498Ssam	cmpl	(r1),12(fp)
5613498Ssam	beql	done
5713498Ssam	blssu	botch
5813498Ssam	movl	$loop,16(fp)
5913498Ssam	ret				# pop another frame
6013498Ssam
6113498Ssamdone:
6213498Ssam	cmpb	*16(fp),reiins		# returning to an "rei"?
6313498Ssam	bneq	1f
6413498Ssam	movab	3f,16(fp)		# do return w/ psl-pc pop
6513498Ssam	brw	2f
6613498Ssam1:
6713498Ssam	movab	4f,16(fp)		# do standard return
6813498Ssam2:
6913498Ssam	ret				# unwind stack before signals enabled
7013498Ssam3:
7113498Ssam	addl2	$8,sp			# compensate for PSL-PC push
7213498Ssam4:
7313498Ssam	jmp	*4(r1)			# done, return....
7413498Ssam
7513498Ssambotch:
7625784Smckusick	calls	$0,_longjmperror
7713498Ssam	halt
7825922Skarels
7925922Skarels	.data
8025922Skarelsreiins: rei
81