1987-01-27 15:57:55 +00:00
|
|
|
#
|
|
|
|
mes 2,EM_WSIZE,EM_PSIZE
|
|
|
|
|
1988-04-20 15:33:17 +00:00
|
|
|
;
|
|
|
|
; layout of a setjmp buffer:
|
|
|
|
;
|
|
|
|
; -----------------
|
1988-04-21 10:08:56 +00:00
|
|
|
; | signal mask | (only for Berkeley 4.[2-])
|
1988-04-20 15:33:17 +00:00
|
|
|
; -----------------
|
|
|
|
; | |
|
|
|
|
; | GTO descriptor |
|
|
|
|
; | (SP, LB, PC) |
|
|
|
|
; | |
|
|
|
|
; -----------------
|
|
|
|
;
|
|
|
|
; setjmp saves the signalmask, PC, SP, and LB of caller, and creates a
|
1988-04-20 16:58:29 +00:00
|
|
|
; GTO descriptor from this.
|
|
|
|
; The big problem here is how to get the return address, i.e. the PC of
|
1988-04-20 15:33:17 +00:00
|
|
|
; the caller; This problem is solved by the front-end, which must pass
|
|
|
|
; it as an extra parameter to setjmp.
|
1987-01-27 15:57:55 +00:00
|
|
|
|
1988-04-21 10:08:56 +00:00
|
|
|
; a GTO descriptor must be in the global data area
|
1988-04-20 15:33:17 +00:00
|
|
|
gtobuf
|
|
|
|
bss 3*EM_PSIZE,0,0
|
1987-01-27 15:57:55 +00:00
|
|
|
|
1988-04-20 15:33:17 +00:00
|
|
|
inp $fill_ret_area
|
|
|
|
exp $setjmp
|
|
|
|
pro $setjmp,0
|
1988-02-16 17:48:39 +00:00
|
|
|
#ifdef __BSD4_2
|
1988-04-21 10:08:56 +00:00
|
|
|
; save mask of currently blocked signals.
|
|
|
|
; longjmp must restore this mask
|
1988-02-16 17:48:39 +00:00
|
|
|
loc 0
|
|
|
|
cal $sigblock
|
|
|
|
asp EM_WSIZE
|
|
|
|
lfr EM_WSIZE
|
1987-01-27 15:57:55 +00:00
|
|
|
lal 0
|
|
|
|
loi EM_PSIZE
|
1988-04-20 16:58:29 +00:00
|
|
|
stf 3*EM_PSIZE
|
1988-04-20 15:33:17 +00:00
|
|
|
#endif
|
1988-04-21 10:08:56 +00:00
|
|
|
; create GTO descriptor for longjmp
|
1988-04-20 15:33:17 +00:00
|
|
|
lxl 0
|
|
|
|
dch ; Local Base of caller
|
|
|
|
lxa 0 ; Stackpointer of caller
|
|
|
|
lal EM_PSIZE
|
1988-04-21 10:08:56 +00:00
|
|
|
loi EM_PSIZE ; Return address of caller
|
1987-01-27 15:57:55 +00:00
|
|
|
lal 0
|
1988-04-21 10:08:56 +00:00
|
|
|
loi EM_PSIZE ; address of jmpbuf
|
|
|
|
sti 3*EM_PSIZE ; LB, SP, and PC stored in jmpbuf
|
1987-01-27 15:57:55 +00:00
|
|
|
loc 0
|
1988-04-21 10:08:56 +00:00
|
|
|
ret EM_WSIZE ; setjmp must return 0
|
1988-04-20 15:33:17 +00:00
|
|
|
end 0
|
|
|
|
|
|
|
|
pro $fill_ret_area,0
|
1988-04-21 10:08:56 +00:00
|
|
|
; put argument in function result area
|
1988-04-20 16:58:29 +00:00
|
|
|
lol 0
|
1988-04-20 15:33:17 +00:00
|
|
|
ret EM_WSIZE
|
|
|
|
end 0
|
|
|
|
|
|
|
|
exp $longjmp
|
|
|
|
pro $longjmp,?
|
1988-04-21 10:08:56 +00:00
|
|
|
#ifdef __BSD4_2
|
|
|
|
; restore signal mask
|
1987-01-27 15:57:55 +00:00
|
|
|
lal 0
|
|
|
|
loi EM_PSIZE
|
1988-04-20 16:58:29 +00:00
|
|
|
lof 3*EM_PSIZE
|
1988-02-16 17:48:39 +00:00
|
|
|
cal $sigsetmask
|
|
|
|
asp EM_WSIZE
|
|
|
|
lfr EM_WSIZE
|
|
|
|
asp EM_WSIZE
|
|
|
|
#endif
|
1988-04-21 10:08:56 +00:00
|
|
|
lal 0
|
|
|
|
loi EM_PSIZE ; address of jmpbuf
|
1988-04-20 16:58:29 +00:00
|
|
|
lae gtobuf
|
1988-04-21 10:08:56 +00:00
|
|
|
blm 3*EM_PSIZE ; fill GTO descriptor from jmpbuf
|
|
|
|
lol EM_PSIZE ; second parameter of longjmp: the return value
|
1987-01-27 15:57:55 +00:00
|
|
|
dup EM_WSIZE
|
|
|
|
zne *3
|
1988-04-21 10:08:56 +00:00
|
|
|
; of course, longjmp may not return 0!
|
1987-01-27 15:57:55 +00:00
|
|
|
asp EM_WSIZE
|
|
|
|
loc 1
|
|
|
|
3
|
1988-04-21 10:08:56 +00:00
|
|
|
; put return value in function result area
|
1988-04-20 16:58:29 +00:00
|
|
|
cal $fill_ret_area
|
|
|
|
asp EM_WSIZE
|
|
|
|
gto gtobuf ; there we go ...
|
1988-04-21 10:08:56 +00:00
|
|
|
; ASP and GTO do not damage function result area
|
1988-04-20 15:33:17 +00:00
|
|
|
end 0
|