121431Sdist/* 221431Sdist * Copyright (c) 1983 Regents of the University of California. 3*34480Sbostic * All rights reserved. 4*34480Sbostic * 5*34480Sbostic * Redistribution and use in source and binary forms are permitted 6*34480Sbostic * provided that this notice is preserved and that due credit is given 7*34480Sbostic * to the University of California at Berkeley. The name of the University 8*34480Sbostic * may not be used to endorse or promote products derived from this 9*34480Sbostic * software without specific written prior permission. This software 10*34480Sbostic * is provided ``as is'' without express or implied warranty. 1121431Sdist */ 1213419Sroot 13*34480Sbostic#if defined(SYSLIBC_SCCS) && !defined(lint) 14*34480Sbostic_sccsid:.asciz "@(#)setjmp.s 5.7 (Berkeley) 05/25/88" 15*34480Sbostic#endif /* SYSLIBC_SCCS and not lint */ 1621431Sdist 1713419Sroot/* 1813419Sroot * C library -- setjmp, longjmp 1913419Sroot * 2013419Sroot * longjmp(a,v) 2113419Sroot * will generate a "return(v)" from 2213419Sroot * the last call to 2313419Sroot * setjmp(a) 2413419Sroot * by restoring registers from the stack, 2518292Smckusick * and a struct sigcontext, see <signal.h> 2613419Sroot */ 2713419Sroot 2813419Sroot#include "DEFS.h" 2913419Sroot 3018715SmckusickENTRY(setjmp, R6) 3118715Smckusick movl 4(ap),r6 # construct sigcontext 3218292Smckusick subl2 $8,sp # space for current struct sigstack 3318292Smckusick pushl sp # get current values 3418292Smckusick pushl $0 # no new values 3518292Smckusick calls $3,_sigstack # pop args plus signal stack value 3624300Smckusick movl (sp)+,(r6)+ # save onsigstack status of caller 3713419Sroot pushl $0 3813419Sroot calls $1,_sigblock # get signal mask 3918715Smckusick movl r0,(r6)+ # save signal mask of caller 4018292Smckusick movl (ap),r0 4118715Smckusick moval 4(ap)[r0],(r6)+ # save sp of caller 4218715Smckusick movl 12(fp),(r6)+ # save frame pointer of caller 4318715Smckusick movl 8(fp),(r6)+ # save argument pointer of caller 4418715Smckusick movl 16(fp),(r6)+ # save pc of caller 4518715Smckusick movpsl (r6) # save psl of caller 4618715Smckusick movw 4(fp),(r6) 4713419Sroot clrl r0 4813419Sroot ret 4913419Sroot 5017329SsamENTRY(longjmp, 0) 5113419Sroot movl 8(ap),r0 # return(v) 5213419Sroot movl 4(ap),r1 # fetch buffer 5318292Smckusick tstl 12(r1) 5413419Sroot beql botch 5513419Srootloop: 5618292Smckusick cmpl 12(r1),fp # are we there yet? 5718292Smckusick beql done 5818292Smckusick blssu botch 5918292Smckusick moval 20(fp),r2 6018292Smckusick blbc 6(fp),1f # was r0 saved? 6118292Smckusick movl r0,(r2)+ 6213419Sroot1: 6318292Smckusick bbc $1,6(fp),2f # was r1 saved? 6418292Smckusick movl r1,(r2) 6513419Sroot2: 6613419Sroot movl $loop,16(fp) 6713419Sroot ret # pop another frame 6813419Sroot 6913419Srootdone: 7018292Smckusick pushl r1 # pointer to sigcontext 7118292Smckusick calls $1,_sigreturn # restore previous context 7218292Smckusick # we should never return 7313419Srootbotch: 7425784Smckusick calls $0,_longjmperror 7513419Sroot halt 76