xref: /dflybsd-src/stand/lib/i386/_setjmp.S (revision 479ab7f0492f2a51b48e8537e4f1dc686fc6014b)
1*479ab7f0SSascha Wildner/*-
2*479ab7f0SSascha Wildner * Copyright (c) 1990 The Regents of the University of California.
3*479ab7f0SSascha Wildner * All rights reserved.
4*479ab7f0SSascha Wildner *
5*479ab7f0SSascha Wildner * This code is derived from software contributed to Berkeley by
6*479ab7f0SSascha Wildner * William Jolitz.
7*479ab7f0SSascha Wildner *
8*479ab7f0SSascha Wildner * Redistribution and use in source and binary forms, with or without
9*479ab7f0SSascha Wildner * modification, are permitted provided that the following conditions
10*479ab7f0SSascha Wildner * are met:
11*479ab7f0SSascha Wildner * 1. Redistributions of source code must retain the above copyright
12*479ab7f0SSascha Wildner *    notice, this list of conditions and the following disclaimer.
13*479ab7f0SSascha Wildner * 2. Redistributions in binary form must reproduce the above copyright
14*479ab7f0SSascha Wildner *    notice, this list of conditions and the following disclaimer in the
15*479ab7f0SSascha Wildner *    documentation and/or other materials provided with the distribution.
16*479ab7f0SSascha Wildner * 3. Neither the name of the University nor the names of its contributors
17*479ab7f0SSascha Wildner *    may be used to endorse or promote products derived from this software
18*479ab7f0SSascha Wildner *    without specific prior written permission.
19*479ab7f0SSascha Wildner *
20*479ab7f0SSascha Wildner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*479ab7f0SSascha Wildner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*479ab7f0SSascha Wildner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*479ab7f0SSascha Wildner * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*479ab7f0SSascha Wildner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*479ab7f0SSascha Wildner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*479ab7f0SSascha Wildner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*479ab7f0SSascha Wildner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*479ab7f0SSascha Wildner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*479ab7f0SSascha Wildner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*479ab7f0SSascha Wildner * SUCH DAMAGE.
31*479ab7f0SSascha Wildner *
32*479ab7f0SSascha Wildner * $FreeBSD: src/lib/libstand/i386/_setjmp.S,v 1.3 1999/08/28 00:05:37 peter Exp $
33*479ab7f0SSascha Wildner */
34*479ab7f0SSascha Wildner
35*479ab7f0SSascha Wildner/*
36*479ab7f0SSascha Wildner * C library -- _setjmp, _longjmp
37*479ab7f0SSascha Wildner *
38*479ab7f0SSascha Wildner *	_longjmp(a,v)
39*479ab7f0SSascha Wildner * will generate a "return(v)" from the last call to
40*479ab7f0SSascha Wildner *	_setjmp(a)
41*479ab7f0SSascha Wildner * by restoring registers from the environment 'a'.
42*479ab7f0SSascha Wildner * The previous signal state is NOT restored.
43*479ab7f0SSascha Wildner */
44*479ab7f0SSascha Wildner
45*479ab7f0SSascha Wildner#include <machine/asm.h>
46*479ab7f0SSascha Wildner
47*479ab7f0SSascha WildnerENTRY(_setjmp)
48*479ab7f0SSascha Wildner	movl	4(%esp),%eax
49*479ab7f0SSascha Wildner	movl	0(%esp),%edx
50*479ab7f0SSascha Wildner	movl	%edx, 0(%eax)		/* rta */
51*479ab7f0SSascha Wildner	movl	%ebx, 4(%eax)
52*479ab7f0SSascha Wildner	movl	%esp, 8(%eax)
53*479ab7f0SSascha Wildner	movl	%ebp,12(%eax)
54*479ab7f0SSascha Wildner	movl	%esi,16(%eax)
55*479ab7f0SSascha Wildner	movl	%edi,20(%eax)
56*479ab7f0SSascha Wildner	xorl	%eax,%eax
57*479ab7f0SSascha Wildner	ret
58*479ab7f0SSascha WildnerEND(_setjmp)
59*479ab7f0SSascha Wildner
60*479ab7f0SSascha WildnerENTRY(_longjmp)
61*479ab7f0SSascha Wildner	movl	4(%esp),%edx
62*479ab7f0SSascha Wildner	movl	8(%esp),%eax
63*479ab7f0SSascha Wildner	movl	0(%edx),%ecx
64*479ab7f0SSascha Wildner	movl	4(%edx),%ebx
65*479ab7f0SSascha Wildner	movl	8(%edx),%esp
66*479ab7f0SSascha Wildner	movl	12(%edx),%ebp
67*479ab7f0SSascha Wildner	movl	16(%edx),%esi
68*479ab7f0SSascha Wildner	movl	20(%edx),%edi
69*479ab7f0SSascha Wildner	testl	%eax,%eax
70*479ab7f0SSascha Wildner	jnz	1f
71*479ab7f0SSascha Wildner	incl	%eax
72*479ab7f0SSascha Wildner1:	movl	%ecx,0(%esp)
73*479ab7f0SSascha Wildner	ret
74*479ab7f0SSascha WildnerEND(_longjmp)
75