         PCC      0
*        704752   SIGMA 5/7         BPM M:ENTRY
         SYSTEM   UTS
         DEF      ENTRY
ENTRY    EQU      %
*                                  ENTRY
         DEF      CAL1P             ENTRY FOR CAL1 PROCESSING
         PAGE
         PAGE
*                 SYMBOLIC REGISTER DEFINITIONS.
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
         PAGE
         REF      J:JIT
         REF      TEMP,TEMP1
         REF      TEMP2
         REF      NOPPSD,STKLPSD,FIXOVPSD,FLTFPSD,DECFPSD
         REF      NAOMASK,PSMASK,FXMASK,FLTMASK,DECMASK
         REF      UNIMPPSD,CAL1PSD
         REF      CAL2PSD
         REF      CAL3PSD
         REF      CAL4PSD
         REF      CALBAD
         REF      SAVEREGS
         REF      RCVPSD
         REF      Y008
         REF      J:ALB,TEMP%BREG
         REF      M17
         REF      Y004
         REF      CTRAPSD
         REF      TPSDBASE
         REF      40TRAP
         REF      PULLE1
         REF      TRAPPSD
         REF      S:CLOCK4          CLOCK4 DIRECTOR
         REF      J:OVHTIM          OVERHEAD TIME COUNTER
         SREF     T:SPARK           ENTRY TO PARK SLAVE USER
         SREF     T:SCRASH          ENTRY FOR SLAVE UNMAPPED CRASH
         REF      S:PNO
         REF      S:CUN
         REF      YFF
         PAGE
*
*        PSD TO GO UMPAPPED
*
CTRP2U   :PSD     (IA,CTRP2),INH,(WK,1)
*
*        PROC TO GENERATE TRAP RECEIVING SEQUENCE
*
RTRAP    CNAME    0
         PROC
LF(1)    EQU      %
         DEF      LF(1)
         STCF     PULLE1+1          SAVE TRAP CONDITION CODES
         XW,R0    TEMP%BREG         SAVE R0
         RD,R0    X'31D'            READ LAST BRANCH REG (Q29)
         XPSD,10  CTRAPSD           MERGE WITH COMMON HANDLER
AF(1)    EQU      %                 FOR BASE VALUE
         PEND
         PAGE
         PAGE
***************************************************************
*              TRAP HANDLER TRANSFER VECTOR                   *
***************************************************************
         SPACE    2
NOPPGM   RTRAP    XPSDV             NON-ALLOWED OPERATION TRAP
UNIMP    RTRAP                      UNIMPLEMENTED INSTRUCTION
STKOVF   RTRAP                      STACK OVERFLOW/UNDERFLOW
FIXOVF   RTRAP                      FIXED POINT ARITHMETIC
FLTFLT   RTRAP                      FLOATING POINT ARITHMETIC
DECFLT   RTRAP                      DECIMAL ARITHMETIC FAULT
CAL2XXX  RTRAP                      CAL2
CAL3XXX  RTRAP                      CAL3
CAL4XXX  RTRAP                      CAL4
CAL1PA   RTRAP                      CAL1 NOT CAL1,1
         PAGE
***************************************************************
*             LOCATOR VECTOR FOR USER PSD                     *
***************************************************************
         SPACE    2
:TPSD    COM,8    DA(AF(1))-DA(TPSDBASE)
*
TPSDV    :TPSD    NOPPSD            TRAP 40
         :TPSD    UNIMPPSD          TRAP 41
         :TPSD    STKLPSD           TRAP 42
         :TPSD    FIXOVPSD          TRAP 43
         :TPSD    FLTFPSD           TRAP 44
         :TPSD    DECFPSD           TRAP 45
         :TPSD    CAL2PSD           TRAP 49
         :TPSD    CAL3PSD           TRAP 4A
         :TPSD    CAL4PSD           TRAP 4B
         :TPSD    CAL1PSD           TRAP 48
         BOUND    4
         PAGE
         PAGE
***************************************************************
*                        TRAP MASKS                           *
***************************************************************
         SPACE    2
TMSK     RES      0
         DATA,1   NAOMASK           TRAP 40 - NAO
         DATA,1   0                 TRAP 41 - UNIMP
         DATA,1   PSMASK            TRAP 42 - STACK
         DATA,1   FXMASK            TRAP 43 - FIXED POINT
         DATA,1   FLTMASK           TRAP 44 - FLOATING POINT
         DATA,1   DECMASK           TRAP 45 - DECIMAL ARITH
*        DATA,1   0                 TRAP 49 - CAL2
*        DATA,1   0                 TRAP 4A - CAL3
*        DATA,1   0                 TRAP 4B - CAL4
*        DATA,1   0                 TRAP 48 - CAL1
         BOUND    4
         PAGE
***************************************************************
*                       TRAP ADDRESS                          *
***************************************************************
         SPACE    2
TADR     RES      0
         DATA,1   X'40'             TRAP 40
         DATA,1   X'41'             TRAP 41
         DATA,1   X'42'             TRAP 42
         DATA,1   X'43'             TRAP 43
         DATA,1   X'44'             TRAP 44
         DATA,1   X'45'             TRAP 45
         DATA,1   X'49'             TRAP 49
         DATA,1   X'4A'             TRAP 4A
         DATA,1   X'4B'             TRAP 4B
         DATA,1   X'48'             TRAP 48
         BOUND    4
         PAGE
***************************************************************
*                    TRAP TRANSFER VECTOR                     *
***************************************************************
         SPACE    2
:TRP     COM,8    AF(1)-TRAPBASE
         SPACE    2
TRPTV    RES      0
         :TRP     TRAPS             TRAP 40
         :TRP     TRAPS             TRAP 41
         :TRP     TRAPS             TRAP 42
         :TRP     TRAPS             TRAP 43
         :TRP     TRAPS             TRAP 44
         :TRP     TRAPS             TRAP 45
         :TRP     CAL234            TRAP 49 - CAL2
         :TRP     CAL234            TRAP 4A - CAL3
         :TRP     CAL234            TRAP 4B - CAL4
         :TRP     CAL1PP            TRAP 48 - CAL1
         BOUND    4
         PAGE
***************************************************************
*             COMMON TRAP PROCESSING                          *
***************************************************************
         SPACE    2
T:CTRAPM RES      0
         AI,R0    -1                BACK IT UP TO BRANCH
         XW,R0    TEMP%BREG         AND STORE IT
         STD,R6   TEMP              SAVE R6,R7
         LI,R6    -XPSDV            FORM INDEX
         AW,R6    CTRAPSD           TO GET REAL PSD
         AND,R6   M17               SCRUB
         SLS,R6   -2                DIVIDE BY 4
*                                   NUMBER OF INST IN RTRAP
         LB,R7    TPSDV,R6          GET INDEX TO REAL PSD
         STW,R6   PULLE1            SAVE INDEX
         LD,R6    TPSDBASE,R7       GET PSD
         STD,R6   TRAPPSD           SAVE PSD FOR RECOVERY
         MTW,0    S:PNO             CHECK FOR SLAVE
         BNEZ     CTRP3             YES, SLAVE CPU
         CW,R6    Y004              CHECK FOR MAP
         BANZ     CTRP2             YES, WE ARE MAPPED
         LPSD,8   CTRP2U            UNMAP
CTRP2    STW,R0   TEMP2             SAVE R0
         LH,R0    TSTACK+1
         CI,R0    19                CHECK FOR STACK SPACE
         BGE      CTRP3             ALL OK
         LW,R0    TEMP2             RESTORE 0
         LD,R6    TEMP1              AND R6,R7
SCR79    SUA      X'79'             SUA 79
CTRP3    LW,R0    TEMP2             RESTORE 0
         MTW,0    S:CUN             SLAVE UN=0 IF NO CURRENT USER
*                                   MASTER S:CUN IS ALWAYS NONZERO
         BEZ      T:SCRASH          BAD, UNMAPPED TRAP IN SLAVE CPU
         PUSH     6,R13             SAVE REGS
         LD,R0    R6                GET PSD
         LD,R6    TEMP              RESTORE REGS
         BAL,R2   T:SAVE            SAVE STANDARD ENV
         LW,R1    PULLE1            RESTORE INDEX
         LB,R2    TRPTV,R1          GET ADDRESS OF PROCESSING ROUTINE
         LI,R14   J:OVHTIM          SET CLOCK TO OVERHEAD
         STW,R14  S:CLOCK4          ACCOUNTING
         LI,R3    0                 MOVE BREG
         XW,R3    TEMP%BREG         AND ZAP
         STW,R3   J:ALB             SAVE IN JIT
         LI,R5    J:JIT             SET JIT ADDRESS
         LW,R3    S:PNO             CHECK FOR MASTER CPU
         STB,R3   J:ALB             SET CPU# INTO LAST BRANCH
         BEZ      CTRP4             YES
         BAL,R11  T:SPARK           PARK SLAVE CPU USER AND SIGNAL
*                                   MASTER CPU FOR SCHED SERVICE
CTRP4    LB,R6    TADR,R1           GET TRAP ADDRESS
         LW,R7    YFF               MASK
         LS,R6    PULLE1+1          GET TRAP CC
         LB,R3    PULLE1+1          GET TRAP COND CODE
         ENABLE
         B        TRAPBASE,R2       GO TO PROPER ROUTINE
         PAGE
***************************************************************
*                   TRAP PROCESSING ROUTINES                  *
***************************************************************
         SPACE    2
TRAPBASE RES      0
CAL234   RES      0
         LI,R14   X'B2'             ERROR CODE
         B        CALBAD            BAD CAL
         SPACE    2
TRAPS    LB,R3    TMSK,R1           GET TRAP MASK
         LB,R1    R6                GET TRAPPSD
         SLS,R1   4                 ALIGN
         OR,R1    R6                MERGE WITH TRAP ADDRESS
         B        40TRAP            AND GO
         SPACE    2
         PAGE
***************************************************************
*                      CAL1 PROCESSOR                         *
***************************************************************
         SPACE    2
CAL1P    BCR,14   CAL11N            SELECT CAL1,1
         B        CAL1PA            OTHER CAL1
CAL1PP   B        CAL1P11           NORMAL CAL1 PROCESSING
         PAGE
*                 CAL1 PROCESSOR. USED FOR ALL MONITOR PROCEDURES.
*                 CHECK FOR EXECUTION FROM REGISTER, IND. ADDR., INDEX,
*                 EXU
        REF      CAL1P11
CAL11N   BCS,1    CAL11N1           SELECT CAL1,1
         B        CAL1P+1           NOT CAL1,1
CAL11N1  LC      *CAL1PSD           CHK FOR EXU
         BCR,6    CAL11N2           BRANCH IF NOT
         LCI      1                 RESTORE ORIGINAL CC
         B        CAL1P+1           USE OLD PATH
CAL11N2  STW,1    J:BASE            SAVE
         REF      J:BASE,CAL11N3,J:CALCNT
         LI,1     19+8              OPEN UP
         MSP,1    TSTACK             THE STACK
         LI,1     -15-8             REGISTER 0
         AW,1     TSTACK             STORAGE LOC
         XW,1     J:BASE            RESTORE REG 1
         LCI      0                 STASH
         STM,0   *J:BASE             THE REGISTERS
         ANLZ,7  *CAL1PSD           ADDRESS OF FPT
         CI,7     15                CHK 4 REGISTER
         BG       %+2               SKIP IF NOT
         AW,7     J:BASE            STACK STRGE FOR REGISTERS
         LD,0     CAL1PSD           STASH
         LI,3     X'1FFFF'           THE
         STD,0   *J:BASE,3            PSD
         ENABLE                     LET 'EM COME
         MTW,1    J:CALCNT          BUMP COUNT OF CALS
         LI,5     J:JIT             INITIALIZE
         LW,6     0,7               GET DCB ADDRESS
         BGEZ     CAL11N3           BRANCH IF NOT INDIRECTLY ADDRESSED
         LB,8     6                 GET
         AI,8     -X'80'             FUNCTION CODE
         CI,6     X'1FFF0'          CHK
         BANZ     %+2                NOT REG
         AW,6     J:BASE            STACK ADDRESS OF REGISTER
         LW,6     0,6               DCB ADDR
         LW,R11   S:PNO             CHECK FOR SLAVE
         BEZ      CAL11N3+1         NO
         BAL,R11  T:SPARK           YES
         B        CAL11N3+1
ENTRYSZ  EQU      %-ENTRY
         END

