1*13419Sroot/* setjmp.s 4.1 83/06/27 */ 2*13419Sroot 3*13419Sroot/* 4*13419Sroot * C library -- setjmp, longjmp 5*13419Sroot * 6*13419Sroot * longjmp(a,v) 7*13419Sroot * will generate a "return(v)" from 8*13419Sroot * the last call to 9*13419Sroot * setjmp(a) 10*13419Sroot * by restoring registers from the stack, 11*13419Sroot * previous signal mask, and doing a return. 12*13419Sroot * 13*13419Sroot * BUG: always restores onsigstack state to 0 14*13419Sroot */ 15*13419Sroot 16*13419Sroot#include "DEFS.h" 17*13419Sroot 18*13419SrootENTRY(setjmp) 19*13419Sroot pushl $0 20*13419Sroot calls $1,_sigblock # get signal mask 21*13419Sroot movl r0,r1 22*13419Sroot movl 4(ap),r0 23*13419Sroot movl 12(fp),(r0) # save frame pointer of caller 24*13419Sroot movl 16(fp),4(r0) # save pc of caller 25*13419Sroot movl r1,8(r0) # save signal mask 26*13419Sroot clrl 12(r0) # XXX (should be onsigstack) XXX 27*13419Sroot clrl r0 28*13419Sroot ret 29*13419Sroot 30*13419SrootENTRY(longjmp) 31*13419Sroot .word 0x0000 32*13419Sroot movl 8(ap),r0 # return(v) 33*13419Sroot movl 4(ap),r1 # fetch buffer 34*13419Sroot tstl (r1) 35*13419Sroot beql botch 36*13419Srootloop: 37*13419Sroot bitw $1,6(fp) # r0 saved? 38*13419Sroot beql 1f 39*13419Sroot movl r0,20(fp) 40*13419Sroot bitw $2,6(fp) # was r1 saved? 41*13419Sroot beql 2f 42*13419Sroot movl r1,24(fp) 43*13419Sroot brb 2f 44*13419Sroot1: 45*13419Sroot bitw $2,6(fp) # was r1 saved? 46*13419Sroot beql 2f 47*13419Sroot movl r1,20(fp) 48*13419Sroot2: 49*13419Sroot cmpl (r1),12(fp) 50*13419Sroot beql done 51*13419Sroot blssu botch 52*13419Sroot movl $loop,16(fp) 53*13419Sroot ret # pop another frame 54*13419Sroot 55*13419Srootdone: 56*13419Sroot cmpb *16(fp),reiins # returning to an "rei"? 57*13419Sroot bneq 1f 58*13419Sroot movab 3f,16(fp) # do return w/ psl-pc pop 59*13419Sroot brw 2f 60*13419Sroot1: 61*13419Sroot movab 4f,16(fp) # do standard return 62*13419Sroot2: 63*13419Sroot ret # unwind stack before signals enabled 64*13419Sroot3: 65*13419Sroot addl2 $8,sp # compensate for PSL-PC push 66*13419Sroot4: 67*13419Sroot pushl 8(r1) # old signal mask 68*13419Sroot pushl 12(r1) # old onsigstack 69*13419Sroot chmk $139 # restore previous signal context 70*13419Sroot jmp *4(r1) # done, return.... 71*13419Sroot 72*13419Srootbotch: 73*13419Sroot pushl $14 74*13419Sroot pushl $msg 75*13419Sroot pushl $2 76*13419Sroot calls $3,_write 77*13419Sroot halt 78*13419Sroot 79*13419Srootmsg: .byte 'l, 'o, 'n, 'g, 'j, 'm, 'p, ' , 'b, 'o, 't, 'c, 'h, 012 80*13419Srootreiins: rei 81