121418Sdist/* 221418Sdist * Copyright (c) 1980 Regents of the University of California. 321418Sdist * All rights reserved. The Berkeley software License Agreement 421418Sdist * specifies the terms and conditions for redistribution. 521418Sdist */ 613498Ssam 721418Sdist#ifndef lint 8*25784Smckusick .asciz "@(#)_setjmp.s 5.3 (Berkeley) 01/09/86" 921418Sdist#endif not lint 1021418Sdist 1121418Sdist 1213498Ssam/* 1313498Ssam * C library -- _setjmp, _longjmp 1413498Ssam * 1513498Ssam * _longjmp(a,v) 1613498Ssam * will generate a "return(v)" from 1713498Ssam * the last call to 1813498Ssam * _setjmp(a) 1913498Ssam * by restoring registers from the stack, 2013498Ssam * The previous signal state is NOT restored. 2113498Ssam */ 2213498Ssam 2313498Ssam#include "DEFS.h" 2413498Ssam 2517328SsamENTRY(_setjmp, 0) 2613498Ssam movl 4(ap),r0 2713498Ssam movl 12(fp),(r0) # save frame pointer of caller 2813498Ssam movl 16(fp),4(r0) # save pc of caller 2913498Ssam clrl r0 3013498Ssam ret 3113498Ssam 3217328SsamENTRY(_longjmp, 0) 3313498Ssam movl 8(ap),r0 # return(v) 3413498Ssam movl 4(ap),r1 # fetch buffer 3513498Ssam tstl (r1) 3613498Ssam beql botch 3713498Ssamloop: 3813498Ssam bitw $1,6(fp) # r0 saved? 3913498Ssam beql 1f 4013498Ssam movl r0,20(fp) 4113498Ssam bitw $2,6(fp) # was r1 saved? 4213498Ssam beql 2f 4313498Ssam movl r1,24(fp) 4413498Ssam brb 2f 4513498Ssam1: 4613498Ssam bitw $2,6(fp) # was r1 saved? 4713498Ssam beql 2f 4813498Ssam movl r1,20(fp) 4913498Ssam2: 5013498Ssam cmpl (r1),12(fp) 5113498Ssam beql done 5213498Ssam blssu botch 5313498Ssam movl $loop,16(fp) 5413498Ssam ret # pop another frame 5513498Ssam 5613498Ssamdone: 5713498Ssam cmpb *16(fp),reiins # returning to an "rei"? 5813498Ssam bneq 1f 5913498Ssam movab 3f,16(fp) # do return w/ psl-pc pop 6013498Ssam brw 2f 6113498Ssam1: 6213498Ssam movab 4f,16(fp) # do standard return 6313498Ssam2: 6413498Ssam ret # unwind stack before signals enabled 6513498Ssam3: 6613498Ssam addl2 $8,sp # compensate for PSL-PC push 6713498Ssam4: 6813498Ssam jmp *4(r1) # done, return.... 6913498Ssam 7013498Ssambotch: 71*25784Smckusick calls $0,_longjmperror 7213498Ssam halt 73