xref: /csrg-svn/lib/libc/mips/gen/_setjmp.s (revision 61141)
152705Sbostic/*-
2*61141Sbostic * Copyright (c) 1991, 1993
3*61141Sbostic *	The Regents of the University of California.  All rights reserved.
452705Sbostic *
552705Sbostic * This code is derived from software contributed to Berkeley by
652705Sbostic * Ralph Campbell.
752705Sbostic *
852705Sbostic * %sccs.include.redist.c%
952705Sbostic */
1052705Sbostic
1152856Sralph#include <machine/reg.h>
1255705Sralph#include <machine/machAsmDefs.h>
1352739Sbostic
1452705Sbostic#if defined(LIBC_SCCS) && !defined(lint)
15*61141Sbostic	ASMSTR("@(#)_setjmp.s	8.1 (Berkeley) 06/04/93")
1652705Sbostic#endif /* LIBC_SCCS and not lint */
1752705Sbostic
1852705Sbostic/*
1952705Sbostic * C library -- _setjmp, _longjmp
2052705Sbostic *
2152705Sbostic *	_longjmp(a,v)
2252705Sbostic * will generate a "return(v)" from
2352705Sbostic * the last call to
2452705Sbostic *	_setjmp(a)
2552705Sbostic * by restoring registers from the stack,
2652705Sbostic * The previous signal state is NOT restored.
2752705Sbostic */
2852705Sbostic
2958279Sralph	.set	noreorder
3058279Sralph
3152705SbosticLEAF(_setjmp)
3252705Sbostic	li	v0, 0xACEDBADE			# sigcontext magic number
3352705Sbostic	sw	ra, (2 * 4)(a0)			# sc_pc = return address
3452705Sbostic	sw	v0, (3 * 4)(a0)			#   saved in sc_regs[0]
3552705Sbostic	sw	s0, ((S0 + 3) * 4)(a0)
3652705Sbostic	sw	s1, ((S1 + 3) * 4)(a0)
3752705Sbostic	sw	s2, ((S2 + 3) * 4)(a0)
3852705Sbostic	sw	s3, ((S3 + 3) * 4)(a0)
3952705Sbostic	sw	s4, ((S4 + 3) * 4)(a0)
4052705Sbostic	sw	s5, ((S5 + 3) * 4)(a0)
4152705Sbostic	sw	s6, ((S6 + 3) * 4)(a0)
4252705Sbostic	sw	s7, ((S7 + 3) * 4)(a0)
4352705Sbostic	sw	sp, ((SP + 3) * 4)(a0)
4452705Sbostic	sw	s8, ((S8 + 3) * 4)(a0)
4557856Sralph	cfc1	v0, $31				# too bad cant check if FP used
4652705Sbostic	swc1	$f20, ((20 + 38) * 4)(a0)
4752705Sbostic	swc1	$f21, ((21 + 38) * 4)(a0)
4852705Sbostic	swc1	$f22, ((22 + 38) * 4)(a0)
4952705Sbostic	swc1	$f23, ((23 + 38) * 4)(a0)
5052705Sbostic	swc1	$f24, ((24 + 38) * 4)(a0)
5152705Sbostic	swc1	$f25, ((25 + 38) * 4)(a0)
5252705Sbostic	swc1	$f26, ((26 + 38) * 4)(a0)
5352705Sbostic	swc1	$f27, ((27 + 38) * 4)(a0)
5452705Sbostic	swc1	$f28, ((28 + 38) * 4)(a0)
5552705Sbostic	swc1	$f29, ((29 + 38) * 4)(a0)
5652705Sbostic	swc1	$f30, ((30 + 38) * 4)(a0)
5752705Sbostic	swc1	$f31, ((31 + 38) * 4)(a0)
5852705Sbostic	sw	v0, ((32 + 38) * 4)(a0)
5958279Sralph	j	ra
6052705Sbostic	move	v0, zero
6152705SbosticEND(_setjmp)
6252705Sbostic
6352705SbosticLEAF(_longjmp)
6452705Sbostic	lw	v0, (3 * 4)(a0)			# get magic number
6558279Sralph	lw	ra, (2 * 4)(a0)
6652705Sbostic	bne	v0, 0xACEDBADE, botch		# jump if error
6752705Sbostic	lw	s0, ((S0 + 3) * 4)(a0)
6852705Sbostic	lw	s1, ((S1 + 3) * 4)(a0)
6952705Sbostic	lw	s2, ((S2 + 3) * 4)(a0)
7052705Sbostic	lw	s3, ((S3 + 3) * 4)(a0)
7152705Sbostic	lw	s4, ((S4 + 3) * 4)(a0)
7252705Sbostic	lw	s5, ((S5 + 3) * 4)(a0)
7352705Sbostic	lw	s6, ((S6 + 3) * 4)(a0)
7452705Sbostic	lw	s7, ((S7 + 3) * 4)(a0)
7558791Sralph	lw	v0, ((32 + 38) * 4)(a0)		# get fpu status
7652705Sbostic	lw	sp, ((SP + 3) * 4)(a0)
7752705Sbostic	lw	s8, ((S8 + 3) * 4)(a0)
7852705Sbostic	ctc1	v0, $31
7952705Sbostic	lwc1	$f20, ((20 + 38) * 4)(a0)
8052705Sbostic	lwc1	$f21, ((21 + 38) * 4)(a0)
8152705Sbostic	lwc1	$f22, ((22 + 38) * 4)(a0)
8252705Sbostic	lwc1	$f23, ((23 + 38) * 4)(a0)
8352705Sbostic	lwc1	$f24, ((24 + 38) * 4)(a0)
8452705Sbostic	lwc1	$f25, ((25 + 38) * 4)(a0)
8552705Sbostic	lwc1	$f26, ((26 + 38) * 4)(a0)
8652705Sbostic	lwc1	$f27, ((27 + 38) * 4)(a0)
8752705Sbostic	lwc1	$f28, ((28 + 38) * 4)(a0)
8852705Sbostic	lwc1	$f29, ((29 + 38) * 4)(a0)
8952705Sbostic	lwc1	$f30, ((30 + 38) * 4)(a0)
9052705Sbostic	lwc1	$f31, ((31 + 38) * 4)(a0)
9158279Sralph	j	ra
9252705Sbostic	move	v0, a1
9352705Sbosticbotch:
9452705Sbostic	jal	longjmperror
9558279Sralph	nop
9652705Sbostic	jal	abort
9758279Sralph	nop
9852705SbosticEND(_longjmp)
99