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