SYAOCA    IDENT
SYAOCA    alias     SYM$OUTWARD_CALLER
.
.
.
.------------------------------------------------------------------------
.
. NAME
.    SYP$OUTWARD_CALL
. PURPOSE
.    This procedure is used in the system core to do an outward call to
.    the entry point defined by the job template.
.        . no parameters are passed
.        . the current stack frame is POPed to eliminate active frames
.          and to reset TOS in the exchange package.
. CALLING SEQUENCE
.     PROCEDURE[xref] syp$outward_call (p: ^procedure
.        stack_p: ^cell
.        ring: 0 .. 15)
.------------------------------------------------------------------------
.
.
.  common decks follow: (asmregs, asmintf)
          list     0,0,0
*copyc OSA$BASIC_REGISTER_EQUATES
*copyc SYA$CYBIL_INTERFACE_PROCEDURES
          list     1,1,1
.
.
outcall   ALIAS    SYP$OUTWARD_CALL
outcall   procedur
proc      param    val,pointer
stack_p   param    val,pointer
ring      param    val,subrange,1
.
a_proc    areg     6               .Pointer to CBP.
a_stack   areg     7               .Pointer to stack for outward call.
x_ring    xreg     4               .Ring number for outward call.
.
.  Store a SFSA at the beginning of the stack. The SFSA is generated:
.     P, and A3 are obtained from the CBP of the procedure being called
.     A0, and A1 point to the beginning of the stack segment.
.     A2 is set to NIL.
.     UM is set equal to the live UM at entry to this procedure
.
.
          ploada   a_proc,proc     .Fetch pointer to CBP.
          ploada   a_stack,stack_p .Fetch pointer to stack segment.
          ploadx   x_ring,ring     .Fetch ring number for outward call.
.
          lbyts,6  x1,a_proc,x0,2  .Get pointer to CBP.
          insb     x1,x_ring,x0,2003(8)  .Insert ring number.
          lbyts,2  x2,a2,x0,0      .Get GLOBAL and LOCAL KEYS from PSA.P
          insb     x1,x2,x0,0017(8)  .Insert GLOBAL and LOCAL KEYS in P
          sx       x1,a_stack,0    .Store P in SFSA.
          cpyax    x1,a_stack      .Setup A0 and A1 in SFSA.
          insb     x1,x_ring,x0,2003(8)  .Insert ring number.
          sx       x1,a_stack,8    . Store A0.
          ente     x2,0130(16)     .Insert a frame descriptor for A0 - A3, No X.
          insb     x1,x2,x0,0017(8)
          sx       x1,a_stack,16   .Store A1.
          entl     x0,0E6(16)      .Read the User Mask.
          cpysx    x0,x0
          isom     x1,x0,2020(8),x0  .Build a NIL pointer.
          insb     x1,x0,x0,0017(8)  .Merge UM into NIL pointer word.
          sx       x1,a_stack,24   .Store A2 and User Mask.
          lbyts,6  x1,a_proc,x0,10 .Fetch binding section pointer.
          insb     x1,x_ring,x0,2003(8)  .Insert ring number.
          sx       x1,a_stack,32   .Store A3.
.
.  POP the current stack until beginning of stack is reached.
.
ocpop     pop
          brseg    x1,a2,a0,ocret  .Exit the loop if A2.seg <> A0.seg
          brreq    x0,x0,ocpop
.
. The following field definition is used to support the PSFSA instruction which is
. required for CYBER-2000 but is not available in the ASSEMBLER language yet.
. When it is available, replace the VFD line with the following line:
. ocret     psfsa                    .Purge the SFSA pushdown (CYBER-2000 only)
.
ocret     vfd,16   0701(16)        .Purge SFSA pushdown (CYBER-2000 only)
          cpyaa    a2,a_stack      .Set PSA to point to SFSA.
          return
.
          end
