1eda14cbcSMatt Macy/* 2eda14cbcSMatt Macy * Copyright (c) 1992, 1993 3eda14cbcSMatt Macy * The Regents of the University of California. All rights reserved. 4eda14cbcSMatt Macy * 5eda14cbcSMatt Macy * This software was developed by the Computer Systems Engineering group 6eda14cbcSMatt Macy * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7eda14cbcSMatt Macy * contributed to Berkeley. 8eda14cbcSMatt Macy * 9eda14cbcSMatt Macy * Redistribution and use in source and binary forms, with or without 10eda14cbcSMatt Macy * modification, are permitted provided that the following conditions 11eda14cbcSMatt Macy * are met: 12eda14cbcSMatt Macy * 1. Redistributions of source code must retain the above copyright 13eda14cbcSMatt Macy * notice, this list of conditions and the following disclaimer. 14eda14cbcSMatt Macy * 2. Redistributions in binary form must reproduce the above copyright 15eda14cbcSMatt Macy * notice, this list of conditions and the following disclaimer in the 16eda14cbcSMatt Macy * documentation and/or other materials provided with the distribution. 17eda14cbcSMatt Macy * 4. Neither the name of the University nor the names of its contributors 18eda14cbcSMatt Macy * may be used to endorse or promote products derived from this software 19eda14cbcSMatt Macy * without specific prior written permission. 20eda14cbcSMatt Macy * 21eda14cbcSMatt Macy * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22eda14cbcSMatt Macy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23eda14cbcSMatt Macy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24eda14cbcSMatt Macy * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25eda14cbcSMatt Macy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26eda14cbcSMatt Macy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27eda14cbcSMatt Macy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28eda14cbcSMatt Macy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29eda14cbcSMatt Macy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30eda14cbcSMatt Macy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31eda14cbcSMatt Macy * SUCH DAMAGE. 32eda14cbcSMatt Macy * 33eda14cbcSMatt Macy * $Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp 34eda14cbcSMatt Macy */ 35eda14cbcSMatt Macy 36eda14cbcSMatt Macy#if defined(LIBC_SCCS) && !defined(lint) 37eda14cbcSMatt Macy#if 0 38eda14cbcSMatt Macy .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" 39eda14cbcSMatt Macy#else 40eda14cbcSMatt Macy RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $") 41eda14cbcSMatt Macy#endif 42eda14cbcSMatt Macy#endif /* LIBC_SCCS and not lint */ 43eda14cbcSMatt Macy 44eda14cbcSMatt Macy#define _JB_FP 0x0 45eda14cbcSMatt Macy#define _JB_PC 0x8 46eda14cbcSMatt Macy#define _JB_SP 0x10 47eda14cbcSMatt Macy 48eda14cbcSMatt Macy .register %g2,#ignore 49eda14cbcSMatt Macy .register %g3,#ignore 50eda14cbcSMatt Macy 51eda14cbcSMatt Macy#define ENTRY(x) \ 52eda14cbcSMatt Macy .text ; \ 53*15f0b8c3SMartin Matuska .balign 32 ; \ 54eda14cbcSMatt Macy .globl x ; \ 55eda14cbcSMatt Macy .type x,@function ; \ 56eda14cbcSMatt Macyx: 57eda14cbcSMatt Macy 58eda14cbcSMatt Macy#define END(x) \ 59eda14cbcSMatt Macy .size x, . - x 60eda14cbcSMatt Macy 61eda14cbcSMatt Macy/* 62eda14cbcSMatt Macy * C library -- setjmp, longjmp 63eda14cbcSMatt Macy * 64eda14cbcSMatt Macy * longjmp(a,v) 65eda14cbcSMatt Macy * will generate a "return(v?v:1)" from 66eda14cbcSMatt Macy * the last call to 67eda14cbcSMatt Macy * setjmp(a) 68eda14cbcSMatt Macy * by restoring the previous context. 69eda14cbcSMatt Macy */ 70eda14cbcSMatt Macy 71eda14cbcSMatt MacyENTRY(setjmp) 72eda14cbcSMatt Macy stx %sp, [%o0 + _JB_SP] 73eda14cbcSMatt Macy stx %o7, [%o0 + _JB_PC] 74eda14cbcSMatt Macy stx %fp, [%o0 + _JB_FP] 75eda14cbcSMatt Macy retl 76eda14cbcSMatt Macy clr %o0 77eda14cbcSMatt MacyEND(setjmp) 78eda14cbcSMatt Macy 79eda14cbcSMatt MacyENTRY(longjmp) 80eda14cbcSMatt Macy mov 1, %g1 81eda14cbcSMatt Macy movrnz %o1, %o1, %g1 82eda14cbcSMatt Macy mov %o0, %g2 83eda14cbcSMatt Macy ldx [%g2 + _JB_FP], %g3 84eda14cbcSMatt Macy1: cmp %fp, %g3 85eda14cbcSMatt Macy bl,a 1b 86eda14cbcSMatt Macy restore 87eda14cbcSMatt Macy be,a 2f 88eda14cbcSMatt Macy ldx [%g2 + _JB_SP], %o0 89eda14cbcSMatt Macy 90eda14cbcSMatt Macy.Lbotch: 91eda14cbcSMatt Macy illtrap 92eda14cbcSMatt Macy 93eda14cbcSMatt Macy2: cmp %o0, %sp 94eda14cbcSMatt Macy bge,a 3f 95eda14cbcSMatt Macy mov %o0, %sp 96eda14cbcSMatt Macy b,a .Lbotch 97eda14cbcSMatt Macy nop 98eda14cbcSMatt Macy3: ldx [%g2 + _JB_PC], %o7 99eda14cbcSMatt Macy retl 100eda14cbcSMatt Macy mov %g1, %o0 101eda14cbcSMatt MacyEND(longjmp) 102eda14cbcSMatt Macy 103eda14cbcSMatt Macy#ifdef __ELF__ 104eda14cbcSMatt Macy.section .note.GNU-stack,"",%progbits 105eda14cbcSMatt Macy#endif 106