Home | History | Annotate | Line # | Download | only in gen
_setjmp.S revision 1.1.16.1
      1       1.1  thorpej /*	$NetBSD: _setjmp.S,v 1.1.16.1 2004/07/23 13:59:00 tron Exp $	*/
      2       1.1  thorpej 
      3       1.1  thorpej #include <machine/asm.h>
      4       1.1  thorpej 
      5       1.1  thorpej #if defined(LIBC_SCCS)
      6       1.1  thorpej 	.text
      7       1.1  thorpej 	.asciz "$NetBSD: _setjmp.S,v 1.1.16.1 2004/07/23 13:59:00 tron Exp $"
      8       1.1  thorpej #endif
      9       1.1  thorpej 
     10       1.1  thorpej /*
     11       1.1  thorpej  * C library -- _setjmp, _longjmp
     12       1.1  thorpej  *
     13       1.1  thorpej  *	_longjmp(a,v)
     14       1.1  thorpej  * will generate a "return(v?v:1)" from the last call to
     15       1.1  thorpej  *	_setjmp(a)
     16       1.1  thorpej  * by restoring registers from the stack.
     17       1.1  thorpej  * The previous signal state is NOT restored.
     18       1.1  thorpej  */
     19       1.1  thorpej 
     20       1.1  thorpej ENTRY(_setjmp)
     21  1.1.16.1     tron 	mflr	%r11			/* save return address */
     22  1.1.16.1     tron 	mfcr	%r12			/* save condition register */
     23  1.1.16.1     tron 	mr	%r10,%r1		/* save stack pointer */
     24  1.1.16.1     tron 	mr	%r9,%r2			/* save GPR2 (not needed) */
     25  1.1.16.1     tron 	stmw	%r9,8(%r3)		/* save r9..r31 */
     26  1.1.16.1     tron 	li	%r3,0			/* indicate success */
     27  1.1.16.1     tron 	blr				/* return */
     28       1.1  thorpej 
     29       1.1  thorpej ENTRY(_longjmp)
     30  1.1.16.1     tron 	lmw	%r9,8(%r3)		/* save r9..r31 */
     31  1.1.16.1     tron 	mtlr	%r11			/* restore LR */
     32  1.1.16.1     tron 	mtcr	%r12			/* restore CR */
     33  1.1.16.1     tron 	mr	%r2,%r9			/* restore GPR2 (not needed) */
     34  1.1.16.1     tron 	mr	%r1,%r10		/* restore stack */
     35  1.1.16.1     tron 	or.	%r3,%r4,%r4		/* get return value */
     36  1.1.16.1     tron 	bnelr				/* return if not 0 */
     37  1.1.16.1     tron 	li	%r3,1			/* what's the point? */
     38  1.1.16.1     tron 	blr				/* return */
     39