         DEF      SWAPPER
SWAPPER  RES      0
PMONOFF  EQU      1
DEBUG    EQU      0
RDCK     SET    0        REMOVE READ CHECK CODE..
         SYSTEM   UTS
*                                   SWAPPER
         DEF      LOGOFF
*
*                                   G. A. PERRY
*                                   H. L. SCANTLIN
*************************************
*************************************
* T A B L E   O F   C O N T E N T S
*
         PAGE
         DEF      SPMAP,SWAPIN,SWAPOUT
         DEF      SADRINC
         REF      E:UQFAC
         REF      T:PGCHK,PGCHKM
         REF      TSS2,T:RE
         REF      M8,M7,M15,M17,Y8,Y01,Y02,Y08
         REF      YFF
         REF      X3FFE00,XFFF800,M24,M21
         REF      X8000
         REF      GETJIT,GIVEUP
         PAGE
*************************************
*        ALL REFS                   *
*************************************
*
* USER TABEL REFS
*
         REF      UX:JIT
         REF      UH:FLG
         REF      UH:JIT
         REF      UH:AJIT
         REF      UB:PCT
         REF      UB:ACP
         REF      UB:APR
         REF      UB:APO
         REF      UB:ASP
         REF      UB:DB
         REF      UB:OV
         REF      UB:US
         REF      UB:BL
         REF      UB:PRIO           CURRENT PRIORITY
         REF      S:GJOBACN         GHOST JOB ACCOUNT
         REF      S:CUP
*
* JIT REFERENCES FOR SCHEDULER
*
         REF      J:ASSIGN
         REF      J:JIT
         REF      JXCMAP
         REF      JBNRG
         REF      JBPCC
         REF      JCL               BEG OF CL IF NO AJIT
         REF      JCLPA             COMMAND LIST PHY ADR
         REF      JCLE              CL END IE DISP FROM BEG OF CL
         REF      JCCL              MAX COMMAND CHAIN LENGTH IN JIT
         REF      JCLP              DISP IN CL WHERE TIC WENT
         REF      JCLT              SAVED WORD IN CL WHERE TIC WENT
         DO1      RDCK
         REF      JHSWPCK
         REF      JAJ               AJIT'S PHY PG ADR
         REF      JVLCS             VIRTUAL LINK CHAIN STOP
         REF      JJITVP,JAJITVP
         REF      JXBUFVP,Y008
         REF      JBUPVP,JSBUF1VP,JOVVP
         REF      JSPBFLG
         REF      JH:DA,J:AJIT
         REF      JDA
         REF,1    JB:NFPOOL
         REF      JLMAP,JCMAP
         REF      JPPH,JPPT,JPPC
         REF      HANSWAPS,J:NRS
         REF      JVLH,JVLT
         REF      JPCP
         REF      JBNASP
         REF,1    JB:PRIV
         REF,1    JB:PNR
         REF      PRDCRM
         REF      PRDPRM
         REF      TMDCRM
         REF      TMDPRM
         REF      TMPDCPK
         REF      TMPDPPK
         REF      M:UC
*
* MEM MGMT REFS
*
         REF      T:FPP             FREE PAGE
         REF      MX:PPUT           MONITOR PHYSICAL PAGE TABLES
         REF      FPMC              FREE PG MAP CONSTANT
        REF      NPMC
* LINE TABLE REFS
*
         SREF     LB:UN             LINE TO USER NO TABLE
*
* PERFORMANCE MEASUREMENT REFS
*
PERFORM  EQU      PMONOFF
         REF      DID%IO
         DO PERFORM
         REF      CURNTIM
         REF      OSWAP%MEAS
         REF      ISWAP%MEAS1
         REF      ISWAP%MEAS2
         REF      T:DSTRB,CH:DOS
         FIN
*
* PRDC. TABLE REFERENCES
*
         REF      PX:HPP            HEAD OF PHYSICAL PAGES
         REF      PX:TPP            TAIL        "      "
         REF      PB:PSZ            PROCEDURE SIZE
         REF      PB:DSZ            DATA SIZE
         REF      PB:DCBSZ          DCB SIZE
         REF      PH:PDA            PROCEDURE DISCARD
         REF      PH:DDA            DATA DISC ADD
         REF      PB:PVA            PROCEDURE VIRTUAL ADD
*
*
         REF      T:SEXIT
*
* STEP REF
*
         REF      T:DELUS
         REF      0PSD
*
* SCH DATA REFS
*
         REF      S:HIR
         REF      S:OPC             OVERLAY PROTECTION COUNTER
         REF      SL:OPC            BASE VALUE FOR S:OPC
         REF      ATITLE
         REF      SV:LIM
* SWAPPER REFS
*
         REF      M:HLTIC
         REF      UB:SWAPI
         REF      M:GASLIM
         REF      MB:GAM6
         REF      MB:GAM7
         REF      M:ADRINCR
         REF      UH:FLG2
         REF      TSC3
         REF      TSC4
         REF      SCL%END
         REF      S:BECL
       REF,2    SDA%END
         REF      SX:HPP            HEAD OF SWAPPERE PAGES
         REF      S:ISUN
         REF      SB:NP
         REF      SB:PNL
         REF      S:PCT
         REF      S:FPPH,S:FPPT,S:FPPC
         REF      S:AJP
         REF      SB:OSN
         REF      SB:OSUL
         REF      S:BDA
         REF      SH:EDA
         REF      S:BCL
         REF      S:ECL
         REF      S:SCL
         REF      SH:SDA
         REF      S:JCL
        REF      SH:JAJDA
         REF      CHNMSK
         REF      C0MSK
         DO PERFORM
         REF      TSC0
         FIN
         REF      TSC1
         REF      TSC2
         REF      S:JSP
         DO1      RDCK
         REF      DORDCK
         REF      BANPMC
         DO1      RDCK
         REF      RDCKDSP1,RDCKDSP2,RDCKDSP3,RDCKDSP4
*
* MISC REFS
*
         REF      J:ACCN
         REF      :BIG
         REF      ALLOOUT
         REF      RCVPSD
*        REFERENCES TO USER LIMITS
         REF      S:SYMDB
         REF      SB:RBMX,SB:RGMX,SB:ROMX
         REF      SB:RBDF,SB:RGDF,SB:RODF
         REF      SL:BDF,SL:GDF,SL:ODF
         REF      SL:BMX,SL:GMX,SL:OMX
         REF      J:CCBUF,J:TITLE,JB:CUR,JB:MAX,SV:RSIZ
         REF      MPPO
         REF      MPO
         REF      MDPO
         REF      MUPO
         REF      MAXG
         REF      ONLN,GJOB,JPUF
         REF      DAJ
         REF      SB:GJOBUN
         REF      S:GJOBTBL,T:OV
         PAGE
AJFLGS   EQU      X'2C'             COM CHAIN, INT ON ERROR & HLAT
JFLGS    EQU      X'4C'             INT ON BC=0 OR ERROR, NO COM CHAIN
HFLGS    EQU      X'4C'
JITIC    EQU      HBIT(6)
PPSWAP   EQU      HBIT(11)
SDLAY    EQU      4
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
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
         BOUND    8
CCI      TEXTC    'CCI'
         TEXT     '    '
LOGOFF   TEXTC    'LOGON'
OVSTART  DATA     X'400000'+T:OV
SHSDA    GEN,8,24 3,BA(SH:SDA)
:9AJCL   GEN,8,24  X'03',BA(JH:DA)
         GEN,8,24 X'2E',2
         GEN,8,24 X'02',0
         GEN,8,4,20  X'2C',8,X'800'
         PAGE
*************************************
*                                   *
*        SWAPPER                    *
*                                   *
*************************************
         PAGE
************************************
*        SWAP OUT                  *
************************************
*        1   = RAD TBL INDEX(BYTE 0),AND INDEX TO CL,DA TABLES
*        3  = USER #
*        7  = USERS JIT ADR
*        8  = ACC
*        6  # INDEX FOR ADDRESSING & EDA
*        12 = BCL
*        13 = ECL
*        5  # BA(USERS JIT CL)
*        9  = SEEK ORDER WITH BA(DA TABLE)
*        4  = INDEX TO DA TABLE  FOR JIT CL
*        2  = POINTER TO NEXT CL ENTRY  FOR JIT CL
*  GET # OF USERS TO SWAP OUT
SWAPOUT  EQU      %
         REF      SB:OSULT
         LB,R1    SB:OSN            MOVE USER LIST TO TEMP TABLE
         LI,4     0
         STW,4    #SWAP%DEV
MV%OSUL  EQU      %
         LB,R2    SB:OSUL,R1
         STB,R2   SB:OSULT,R1
         LB,2     UB:SWAPI,2
         LI,3     1
         SLS,3    0,2
         CW,3     4
         BANZ     %+3
         REF      S:#SWAP%DEV
#SWAP%DEV EQU     S:#SWAP%DEV
         MTW,1    #SWAP%DEV
         OR,4     3
         BDR,1    MV%OSUL
         OPEN     SB:OSUL
SB:OSUL  SET      SB:OSULT
         DO       DEBUG
         LI,1     7
         BAL,0    RECORD
         FIN
         LI,1     PGCHKM1
PGCHKS   RES      0
         LI,7     S:FPPH
         B        T:PGCHK
PGCHKM1  BAL,1    PGCHKM
         LI,4     0                 INDEX FOR SDA (FOR JIT CL)
          LW,9    SHSDA             SEEK ORDER
         LI,2     S:SCL             SCL ADR (FOR JIT CL)
         B        SO0
OS%CONT  EQU      %
         LW,2     TSC1              RESTORE 2,4,& 9
         LW,4     TSC2
         LW,9     TSC3
SO0      EQU      %
         LI,R1    0                 INITIALIZE CL,DA TABLES INDEX
         LB,R7    SB:OSN            # USERS IN OUTSWAP LIST
         BEZ      T:SEXIT           BAIL OUT
*        PICK UP ALL USERS THAT GO OUT TO SAME DEVICE
SO0A     EQU      %
         LB,R3    SB:OSUL,R7        GET USER #
         BEZ      SOJ6              THIS ONE ALREADY PROCESSED
         LB,R3    UB:SWAPI,R3       GET RAD INDEX
         AI,R1    0                 IS IT LOOP 1 FOR THIS DEVICE
         BNE      SO0B              NO
         STB,R3   R1                INITIALZE RAD INDEX
SO0B     EQU      %
         CB,R3    R1                DOES USER MATCH DEVICE
         BNE      SOJ6              NO
*  GET USER # & USER'S PHY JIT ADR
         AI,R1    1                 BUMP CL AND DA TABLE INDEX
         PUSH     R7                SAVE INDEX INTO USER LIST
         LB,R3    SB:OSUL,R7        PROCESS THIS USER #
         LOAD,7   UX:JIT,3          GET PP # OF USERS JIT
         SLS,7    9                 JIT ADR
         LW,5     7
         SLS,5    2-:BIG            BA OR HA (JIT ADR)
         LOAD,8   JPPH,5            GET HEAD OF USERS PP CHAIN
         LW,6     S:FPPT            GET TAIL OF SWAPPER FREE PP CHAIN
         BNEZ     SO2               CHAIN HAS BEEN STARTED
*  S:FPP CHAIN MUST BE INITIATED
         STW,8    S:FPPH            TO START CHAIN - HEAD TO HEAD
         B        SO2+1             TAIL TO TAIL
*  ADD TO SWAPPER'S FREE PG POOL
SO2      EQU      %
         STORE,8  MX:PPUT,6         USER HEAD TO PP POINTED TO BY S TAIL
         LOAD,8   JPPT,5            GET USER TAIL
         STW,8    S:FPPT            TO SWAPPER TAIL
*
*        SAVE SPARE BUFFER INDEX IN WINDOW ENTRY.
*
         LI,8     JXCMAP            BYTE DISPLACEMENT INTO JIT
         SLS,8    -:BIG             B/H DISPLACEMENT INTO JIT
         AW,8     5                 B/H ADDR OF CMAP
         LI,6     JAJITVP+1         INDEX TO 1ST WINDOW PG IN CMAP
         AW,6     8                 B/H ADDR OF 1ST WINDOW PG IN CMAP
         LI,12    JBUPVP-1          INDEX TO LAST WINDOW PG IN CMAP
         AW,12    8                 B/H ADDR OF LAST WINDOW PG IN CMAP
         LI,13    JXBUFVP           INDEX TO 1ST SPARE IN CMAP
         AW,13    8                 B/H ADDR OF 1ST SPARE IN CMAP
         PUSH     4
SO22     LI,4     JOVVP-1           INDEX TO LAST SPARE IN CMAP
         AW,4     8                 B/H ADDR OF LAST SPARE IN CMAP
         LOAD,14  0,6               GET PP MAPPED INTO WINDOW
         CI,14    FPMC              IS IT NOW MAPPED
         BE       SO25              NO
SO23     COMPARE,14 0,4             IS IT MAPPED IN THIS SPARE
         BE       SO24              YES
         AI,4     -1                NO-SET TO LOOK AT LOWER SPARE
         CW,4     13                HAVE ALL SPARES BEEN SEARCHED
         BGE      SO23              NO-KEEP LOOKING
         SCREECH X'6B'
SO24     SW,4     8                 CONVERT SPARE B/H ADDR TO VP INDEX
         STORE,4  0,6               PUT INDEX IN WINDOW OF CMAP
SO25     AI,6     1                 NEXT WINDOW PAGE
         CW,6     12                HAVE ALL WINDOWS BEEN SEARCHED
         BLE      SO22              NO
         PULL     4
         LW,13    Y008              FLAG FOR INDICIES IN WINDOW
         STS,13   JSPBFLG,7
*  CLEAR USER'S PP CHAIN HEAD, TAIL & COUNT AND ADD COUNT TO SWAP COUNT
*  IS THE CLEARING NECESSARY ?
         LI,8     0
         STORE,8  JPPH,5            CLEAR USER HEAD
         STORE,8  JPPT,5                       TAIL
         LI,6     HANSWAPS          HA(NUMBER OF OUTSWAPS)
         MTH,1    *7,6              INCREMENT THE COUNT
         BNEZ     %+3               HAVE WE OVERFLOWED
         LI,13    X'10000'          SET OVERFLOW BIT
         STS,13   J:NRS-J:JIT,7
         SLS,5    :BIG              NOP OR SHIFT FROM HA TO BA(JIT)
         LB,12    JPPC,5
         STB,8    JPPC,5
         AWM,12   S:FPPC
*  SET UP OUT SWAP ORDER LIST
         LW,12    JCLPA,7           GET BEG OF CL - PHY ADR
         LW,13    JCLPA,7
         AW,13    JCLE,7            ADD DISP = END OF CL
         STW,13   14
         LI,6     JBNRG             FIND THE END OF THE NON PURE
         LB,8     JPCP,5            PROCEDURE PORTION OF THE
         LB,11    *7,6              CLIST
         AW,11    8
         DW,11    X4
         AW,11    8
         SLS,11   1
         SW,14    11
*  TEST - PURE PROCEDURE SWAP
         LH,0     UH:FLG,3
         LC       J:ASSIGN-J:JIT,5  CHECK FOR LONG TERM
         BCS,2    SO4
         CI,0     PPSWAP            SWAP PURE P TEST
         BANZ     SO4
*  PURE PROCEDURE NOT CHANGED - DON'T SWAP IT - CORRECT ECL
         LB,8     JPCP,5            ANY PP
         BEZ      SO4               NO
         STW,14   13                TRUNCATE CLIST AT END NON-PP
*  PUT IN JIT,DISP OF TIC FROM CL & CONTENTS OF SAME IF GOOD OTHERWISE 0
SO4      EQU      %
         LW,6     *13               SAVE WD WHERE TIC WILL BE INSERTED
         LW,8     13                ECL
         SW,8     12                DISP IN CL WHERE TIC WILL GO
         BNEZ     %+3
         STW,12   S:ECL,1
         B        SOJ1
         LW,10    12
         LW,11    X3FFE00
         CS,10    7
         BNE      %+2
         AW,8     Y8                SET IF CL IN JIT
         STW,8    JCLP,7            SAVE DISP IN JIT
         STW,6    JCLT,7            SAVE WORD THAT TIC DESTROYES
*  RESET PPSWAP
         RSETSST  PPSWP,0,3
*  GET END DA
         LI,6     0
         AI,6     -8
         LB,8     *13,6             SEARCH BACK FROM END OF CL
         CI,8     3                 FOR LAST SEEK IOCD.
         BL       %-3
         SLS,6    -2
         LW,6     *13,6             GET BA OF END DA POINTER
         SLS,6    -1                HA OF END DA POINTER
         AND,6    M24
         LH,6     0,6               END DA
*  SET UP USERS ENTRY IN ORDER TABLES - END OF CL & DA
         STW,13   S:ECL,1
         STH,6    SH:EDA,1
*
         LW,10    Y01               WRITE ORDER
         LW,11    YFF
         PAGE
*************************************
*        SET USER CL TO WRITE       *
*        SET WRITE ORDER IN CL & DO WRITE PART OF RD CK
*        IF NO PHY PG ALLOCATED, PUT USER # IN CL, OTHERWISE
*        SAVE A HALF WD FROM PHY PG IN CL & PUT DA INTO HALF WD
*        SAVE A HALF WD FROM PHY PG IN CL & PUT SWAP ID INTO HALF WD
*        3  = USER #,NOW = Y008, INDICATES NPMC
*        4  = PHY PG MEM ADR
*        5  = MASK FOR COMPARING FOR NO PHY PG
*        6  = ADR OF DA & DA
*        7  = WD 2 OF CL ENTRY
*
         PUSH     7,1
         LW,6     7
         DO1     RDCK
         LI,1     JHSWPCK
         LW,5     M24               BYTE ADR MASK
         LW,7     12                BEGIN CLIST PTR..
         LW,3     Y01
         LI,1     4
SOCK1    AI,7     2                 INC TO NEXT IOCD IN CLIST.
         CW,7     13                CHECK FOR END
         BGE      SOCK8             POSSIBLE
SOCK2    STS,10   0,7               STORE WRITE ORDER
         LW,4     0,7
         CS,4     BANPMC            WAS A PHYSICAL PAGE ASSIGNED
         BNE      %+2
         STS,3    1,7               NO, SET SKIP FLAGS
         BDR,1    SOCK1             DO FOUR COMMANDS.
         AI,7     2                 SKIP SEEK.
         B        SOCK1-1
SOCK8    EQU      %
         PULL     7,1
         LW,R3      *TSTACK         INDEX INTO USER LIST
         LB,R3    SB:OSUL,R3        GET USER #
         PAGE
*************************************
*        SET UP AJIT AND JIT CL     *
*        FOR OUT SWAP USER          *
*************************************
*  SET UP BCL
SOJ1     EQU      %
         STW,2    S:BCL,1           SET BCL
         LH,8     UH:AJIT,3         GET AJIT DISC ADR
         BEZ      SOJ2              NO AJIT
*  SET UP AJIT CL & SET UP BDA
         STH,8    SH:SDA,4          AJIT'S DA TO SHELL DA TABLE
         STW,8    S:BDA,1           SET BDA
         LW,10    JAJ,7             GET AJIT'S PP#
         SLS,10   11
         AW,10    Y01               WRITE ORDER
         STW,10   2,2               AJITS WRITE ORDER AND MEM ADR TO SCL
         STW,9    0,2               SET SEEK WD
         AI,2     4                 UPDATE SCL
         AI,4     1                 UPDATE SDA
         AI,9     2                 UPDATE ADR IN SEEK WD
         B        SOJ4
*  NO AJIT - SET UP BDA
SOJ2     EQU      %
         LH,8     UH:JIT,3          GET JIT'S DA
         STW,8    S:BDA,1           SET UP BDA
*  SET UP JIT CL & PUT TIC TO REMAINDER OF CL
SOJ4     EQU      %
         LH,8     UH:JIT,3          GET JIT'S DA
         LOAD,10  UX:JIT,3          GET JIT PP #
         SLS,10   11                GET JIT'S MEM ADR
         AW,10    Y01               WRITE ORDER
         STW,10   2,2               SET IN SCL, JITS WRT ORDER & MEM ADR
         STW,9    0,2               SET SEEK WD
         STH,8    SH:SDA,4          SET IN SDA, JITS DA
         AI,2     4
         CW,12    S:ECL,1
         BNE      SOJ5
         STW,2    S:ECL,1
         LW,8     S:BDA,1
         STH,8    SH:EDA,1
SOJ5     EQU      %
         AND,12   M21
         SLS,12   -1                COMMAND ARD TO DBL WD
         AW,12    Y08               ADD TCI TO USERS BCL
         STW,12   0,2               TIC FROM JIT'S CL TO USER'S CL
         AI,2     4
         AI,4     2                 UPDATE SDA PAST TIC
         AI,9     4                 UPDATE ADR IN SEEK WD
*  SET STOP OF VIRTUAL LINK CHAIN TO ZERO
         LI,8     0
         STW,8    JVLCS,7           PUT VP # IN VIRT LINK CHAIN STOP
         STW,2    TSC1
         STW,4    TSC2
         STW,9    TSC3
         PULL     R7                GET INDEX INTO USER LIST
         STB,R8   SB:OSUL,R7        FLAG THIS USER ELIMINATED
         LW,12    S:BCL,1
         LW,13    S:ECL,1
         STD,12   S:BECL,7          SAVE FOR ERROR PROCESSING IN TSIO
SOJ6     EQU      %
         BDR,R7   SO0A              GO TRY FOR ANOTHER ONE
         AI,R1    0                 IS EVERYBODY Q'D UP FOR OUTSWAP
         BE       T:SEXIT           YES-(TO SCHDLER, OR INTRPT RETURN)
         LW,R8    R1                CL AND DA TABLE SIZE TO R8 FOR OSAC
         LB,14    1                 RADX T0 14
         PUSH     14
         AND,R8   M8
         PAGE
*************************************
*        SWAP OUT - SORT ORDER CHAIN*
*************************************
*  IF ONE USER SKIP ORDER ETC
         CI,8     1                 IS THERE ONLY ONE OUT SWAP USER
         BNE      SO8               MORE TNAN ONE USER
         LW,5     S:ECL+1           FOR 1, GET ECL
         LW,6     S:BCL+1           FOR 1, GET BCL
         B        SO9
*  DO EVERYTHING FOR MORE THAN ONE USER
SO8      EQU      %
         BAL,15   OSAC              ORDER SORT & CHAIN
         PULL     R14               GET RAD INDEX
         STW,8    TSC4              SAVE USER COUNT
         BAL,15   SENSE             FIND DISC SECTOR
         LB,R14   R14               RADX RETURNED AS END ACTION INFO
         PUSH     R14               SAVE END ACTION INFO
         BAL,15   ULCLC             UNLINK CL CHAIN
*  FOR SIO   6 = BEG OF CHAIN
SO9      EQU      %
         LW,7     *TSTACK           GET RAD INDEX
         LW,R8    M:HLTIC,R7        HALT COMMAND
         STW,8    0,5               SET UP LAST TIC TO THE HALT ORDER
         LI,7     01                WRITE FCN
*
         MTW,-1   DID%IO            SET SWAP OUT I/O FLAG TO 'TRUE'
         DO       PERFORM
         BAL,0    CURNTIM           GET CURRENT TIME
         STW,1    TSC0
  FIN
*
         PULL     R14               GET SWAP RAD INDEX
         LI,11    OS%CONT           RETURN TO OS%CONT FROM TSIO
         PUSH     R11
         BAL,15   SIO
*
 DO PERFORM
         LW,3     TSC0
         PUSH     2,4
         BAL,4    OSWAP%MEAS        RECORD OUT SWAP TIME
         PULL     2,4
 FIN
*
         PAGE
************************************
*        SWAP IN                   *
************************************
*  SWAP IN
SWAPIN   EQU      %
         DO       DEBUG
         LI,1     8
         BAL,0    RECORD
         FIN
SI0      EQU      %
         LW,8     S:FPPC            PG CNT FROM SWAPPER FREE PG POOL
         SW,8     S:PCT             SUBST PG CNT NEEDED FOR IN USER
         BEZ      SI1A
         BGZ      SI1               RELEASE EXTRA PGS
         SCREECH  X'1F'
SI1      EQU      %
*  RELEASE EXTRA PGS
*  I 3 = PG TO RELEASE
*    4 = REG USED INTERNALLY
         LW,3     S:FPPH            1ST PP
         LOAD,1   MX:PPUT,3
         BAL,2    T:FPP
         MTW,-1   S:FPPC
         STW,1    S:FPPH
         BDR,8    SI1
         LW,2     1
         BNEZ %+2
         STW,2 S:FPPT
SI1A     LI,5     0                 CHECK FOR AND CLEAR ALLYCATS FLAG
         XW,5     ALLOOUT
         BEZ      SI1B
         LH,6     UH:FLG,5
         CI,6     JIC
         BAZ      %+3
         STW,5    ALLOOUT
         B        SI1B
         LI,6     E:UQFAC           IT WAS HIM, REPORT IT
         BAL,11   T:RE
SI1B     EQU      %
         LW,5     S:ISUN            ANY INSWAP USER
         BEZ      SIU14             NOPE GET OUT
         LI,1     1
         STW,1    #SWAP%DEV
*
         PAGE
************************************
*        SET UP SWAP IN PROCESSORS *
************************************
*  SET UP TO SWAP IN PROCESSORS
*
*        1 = PROCESSOR LIST INDEX
*        2 = PP #
*        3 = PROC #
*        4 = PROC SIZE (# OF PGS)
*        6 = INDEX TO DA TABLE
*        7 = POINTER TO NEXT CL ENTRY
*        8 = PHY PG ADR IN 3RD WD OF 4 WORD CL
*        9 = MASK FOR STS
*       12 = DA
*        13 = DA MASK
         BAL,1    PGCHKM
         BAL,1    PGCHKS
         LI,7     S:SCL             GET BEG OF SHELL CL
         LI,6     0                 INIT DA TABLE POINTER
          LW,9    SHSDA             SEEK ORDER
         LW,8     S:FPPH            GET 1ST PP #
         LB,1     SB:NP             GET # OF PROCESSORS
         BEZ      SI2               THERE ARE NONE
*  GET NEXT PROCESSOR NUMBER
SIP1     EQU      %
         LB,3     SB:PNL,1          GET PROC #
*  GET PROC SIZE & SET UP BCL & BDA
         LB,4     PB:PSZ,3          GET PROC SEG SIZE
         LCW,12   4
         AWM,12   S:FPPC
         STW,7    S:BCL,1           SET BCL FOR THIS PROCESSOR
         LH,12    PH:PDA,3          GET SEG DISC ADR
         STW,12   S:BDA,1           SET BDA FOR THIS PROC
         STORE,8  SX:HPP,1          SET PROCS TEMP PP HEAD
         B        SIP3+1
*  GET PP #  SET UP CL & DAT FOR PROC IN SHELLS
SIP3     EQU      %
         LOAD,8   MX:PPUT,2         GET A PP # FROM S:FPP
         LW,2     8                 SAME PP # IS INDEX TO NEXT PP #
         AI,8     X'4000'           READ ORDER
         SLS,8    11
         STW,9    0,7               SEEK
         AI,9     2                 TO NEXT DA TABLE ENTRY
         STW,8    2,7               READ & BA(PP ADR)
         STH,12   SH:SDA,6          DA  INTO DA TABLE
         LI,5     0                 SWAPPER INDEX
         BAL,0    SADRINC           INC DISC ADDRESS..
         AI,6     1                 INCR INDEX TO NEXT DA TABLE ENTRY
         AI,7     4                 INCR TO NEXT CL ENTRY
         BDR,4    SIP3              CONT SETTING UP PROCESSOR
*  SET UP ECL & EDA
         STW,7    S:ECL,1           SET ECL FOR THIS PROC
         AI,12    -2                SET TO LAST DA
         STH,12   SH:EDA,1          SET EDA FOR THIS PROC
*  GET NEXT PP # AND SET UP PROC CHAIN'S TAIL
         STORE,2  PX:TPP,3          SET TAIL IN PROC PP TAIL
         LOAD,8   MX:PPUT,2         GET NEXT PP #
         STORE,4  MX:PPUT,2         END PROC CHAIN WIHTH 0
*  INCR CLP PAST SPACE FOR TIC AND GO FOR NEXT PROC
         AI,7     4                 INCR CL POINTER PAST TIC SPACE
         AI,9     2
         AI,6     1
         BDR,1    SIP1              BACK FOR NEXT PROCESSOR
         PAGE
************************************
*        SET UP SWAP IN JIT        *
************************************
*  SET NEW S:FPP HEAD
         STW,8    S:FPPH            UPDATE SWAPPER'S FREE PG POOL HEAD
SI2      EQU      %
*  DETERMINE WHETHER JIT IS IN CORE & SET UP ITS CL IF IT ISN'T
         STW,1    S:AJP             0 TO AJIT PP#
         STW,1    S:JSP             0 TO JIT SECTOR POS
         LW,1     S:ISUN            GET IN SWAP USER #
         LH,0     UH:FLG,1          IS JIT IC
         CI,0     JITIC             JIT IN CORE TEST
         BAZ      SI35
         LOAD,7   UX:JIT,1
         SLS,7    9
         LW,12    JAJ,7             GET AJIT PP #
         STW,12   S:AJP
         B        SIP4
SI35     EQU      %
         LI,7     S:JCL             BEG OF JIT CL
         LI,6     0                 BEG OF JIT DA TABLE
         LW,9     XFFF800           SET UP PHY PG ADR MASK
         LW,8     S:FPPH            GET A PP #
         STW,8    S:AJP             SAVE ALT JIT'S PP #
*  IS THERE AN ALTERNATE JIT - YES, GET AJIT FLAGS - NO, GET JIT FLAGS
         LI,11    AJFLGS            AJIT FLAGS
         LH,12    UH:JIT,1
         BEZ      SIJ4-1
         LH,12    UH:AJIT,1         GET ALT JIT DISC ADR
         BNEZ     SIJ6              NOT = 0, AJIT EXISTS
         STW,12   S:AJP             SET AJIT PP # TO 0
SIJ4     EQU      %
         LI,11    JFLGS             JIT FLAGS (TERMINATES COMMAND CHAIN)
         LH,12    UH:JIT,1          GET JIT DISC ADR
         BNEZ     SIJ6
         LH,2     UH:AJIT,1
         CI,2     -1                CHECK FOR NO JIT DISC
         BNE      SIJ41             NO, HE HAS A SPOT
         LW,4     S:ISUN            GET USER INDEX TO PROPER REG
         LI,0     0                 CLEAR OUTSWAP LIST
         STW,0    SB:OSN            FOR GIVEUP
         LI,11    GIVEUP            SET RETURN
         B        GETJIT
SIJ41    RES      0
         STH,2    UH:JIT,1
         STH,12   UH:AJIT,1
         LI,12    DAJ               ALL JITS COME FROM DAJ
         AI,2     30                DELAY 26 SECTORS ON 7212;
*                                   AND 2 SECTORS ON 7232
         SLS,2    -1                GRAN
         STW,2    S:JSP             PUT INTO JIT AT END OF SWAP
SIJ6     EQU      %
        STH,12   SH:JAJDA,6        DA TO JIT DA TABLE
         LW,2     8                 SAME PP# IS INDEX TO NEXT PP #
         SLS,8    11                CONVERT PP# TO BYTE MEM ADR
         STS,8    2,7               MEM ADR TO CL+2
         AI,7     3                 INCR CL POINTER TO LAST WD OF ENTRY
         STB,11   *7                SET FLAGS
         AI,6     1                 INCR TO NEXT DAT ENTRY
         AI,7     1                 INCR TO NEXT CL ENTRY
         LOAD,8   MX:PPUT,2         GET NEXT PP #
         CI,11    JFLGS             WAS JIT CL SET UP
         BNE      SIJ4              NO AJIT CL - DO JIT
         STORE,2  UX:JIT,1          SET JIT PP #
         STW,8    S:FPPH            UPDATE S:FPPH
SIP4     EQU      %
         LB,R14   UB:SWAPI          GET RAD INDEX
         LB,8     SB:NP             GET # OF PROCESSORS TO SWAP IN
         LI,6     S:JCL
         CI,8     1                 COMPARE # TO ORDER & CHAIN WITH 1
         BG       SI5               MORE THAN ONE PROCESSOR TO SWAP IN
         BL       SI4               NO PROCESSORS
*  ONE PROCESSOR TO SWAP IN  GET BEG & END OF COMMAND CHAIN
         LW,5     S:ECL+1           GET ECL FOR 1 PROC
         LW,6     S:BCL+1               BCL
         B        SI6
*  NO PROCESSORS  MUST JIT COME IN ?
SI4      EQU      %
         CI,0     JITIC
         BANZ     SI10              PROCESSORS AND JIT ARE IN
        LW,5     7
        AI,5     -1
         LI,6     S:JCL             GET JCL ADR FOR SIO
         LW,8     S:JSP
         BNEZ     %+2
         LB,R14   UB:SWAPI,R1       GET RAD INDEX
         B        SI9
*   PROCESSORS TO SWAP  SO SORT, ORDER & CHAIN
SI5      EQU      %
         BAL,15   OSAC              ORDER,SORT & CHAIN
         STW,8    TSC4              SAVE USER COUNT
         BAL,15   SENSE             FIND THE DISC SECTOR
         LB,R14   R14               RADX RETURNED AS END ACTION INFO
*  UNLINK CL CHAIN  INPUT IN 10 = PRESENT SECTOR POSITION
         BAL,15   ULCLC             UNLINK CL CHAIN
*  IS JIT IN CORE - NO, SET TIC - YES, AT END OF PROC CL STOP CHAINING
SI6      EQU      %
         LW,1     S:ISUN
         LH,0     UH:FLG,1
         CI,0     JITIC             IS JIT IN CORE
         BANZ     SI8               YES
*  JIT MUST BE BROUGHT IN
         LB,2     UB:SWAPI,1        GET USERS SWAP TABLE INDEX
         BEZ      SI7               SAME AS PROCESSORS
         LW,8     S:JSP
         BNEZ     SI7
         LI,8     SI65
         PUSH     8
         MTW,1    #SWAP%DEV
         B        SI8
SI65     EQU      %
         LI,6     S:JCL
         LW,1     S:ISUN
         LB,R14   UB:SWAPI,R1       GET RAD INDEX
         B        SI75
SI7      EQU      %
         LI,8     S:JCL             GET JIT CL ADR
         SLS,8    -1
         AW,8     Y08                CREATE TIC
         STW,8    0,5               CORRECT T/C TO JIT CL
SI75     EQU      %
         LI,5     S:JCL+3           END OF JIT CL
         MTW,0    S:AJP           IS THERE AJIT CL
         BEZ      SI9               NO
         AI,5     4                 CORRECTION FOR PRESENCE OF AJIT CL
         B        SI9
*  JIT IS IC SO SET HALT FLAG IN LAST COMMAND
SI8      EQU      %
         AI,5     -1
         LI,8     HFLGS             FLAGS TO STOP COMMAND CHAIN
         STB,8    *5                SET HALT FLG
         PAGE
*  START UP PROC & JIT SWAP IN
SI9      EQU      %
*  FOR SIO  6 = BEG OF CHAIN
         LI,7     02                READ FCN
*
         MTW,2    DID%IO            SET SWAP IN I/O FLAG TO 'TRUE'
         DO       PERFORM
         BAL,0    CURNTIM
         STW,1    TSC0
         FIN
*
         BAL,15   SIO
*
         DO PERFORM
         LW,3     TSC0
         PUSH     2,4
         BAL,4    ISWAP%MEAS1       RECORD IN SWAP TIME
         PULL     2,4
         FIN
*
         PAGE
*************************************
*        PROCESSORS & JIT ARE IN    *
*        CORRECT SHELL CL           *
*        SET HEAD OF PROC CHAIN     *
*************************************
SI10     EQU      %
         LW,1     S:ISUN            IN SWAP USER #
         LOAD,7   UX:JIT,1
         SLS,7    9
         LH,2     UH:FLG2,1
         CI,2     1
         BANZ     S:JITERR
         LW,2     S:JSP
         BEZ      SI105
         LI,2     :BIG
         BEZ      SI102             NOT BIG9
         LW,2     S:FPPH            ALLOCATE AN AJIT FOR BIG9..
         STW,2    S:AJP             SAVE ITS PAGE#
         SLS,2    9
         AI,2     JDA               DISPLACEMENT TO DISC ADDRESS
         LI,4     -JDA              TABLE...
         SLS,4    -1
         LD,8     :9AJCL            DUMMY COMMAND LIST ENTRIES.
         LD,10    :9AJCL+2
SI102A   LI,3     -4
         STD,8    *2,4              STORE SEEK
         AI,8     2                 INC DA ADDRESS
SI102B   BIR,4    %+2
         B        SI102
         STD,10   *2,4              IOCD
         BIR,3    SI102B
         BIR,4    SI102A
SI102    EQU      %
         LH,2     UH:FLG,1
         LD,10    CCI
         LI,4     0
         CI,2     BAT
         BANZ     SI101             BATCH
         LI,5     MAXG
SI10GCK  CB,1     SB:GJOBUN,5
         BNE      SI10NG            NOT GHOST
         LD,10    S:GJOBTBL,5       GET NAME
         LI,4     GJOB              SET JIT FLAG
         LI,8     X'E0'             AND PRIV
         LI,3     JB:PRIV-BA(J:JIT)
         STB,8    *7,3
         LI,3     JB:PNR-BA(J:JIT)
         STB,5    *7,3              GJOBUN GOES IN PNR
         LI,3     TSTACK+5+6-J:JIT  NAME MEBBE GOES IN REGS6-7
         CI,5     1                 UNLESS ITS KEYIN
         BNE      SI105GNK
         LW,8     OVSTART
         STW,8    TSTACK+2-J:JIT,7
         LI,8     T:DELUS           SET LINK REG11
         STW,8    TSTACK+5+11-J:JIT,7
         LI,3     TSTACK+5+2-J:JIT  NAME GOES IN 2-3
SI105GNK LCI      2
         STM,10   *3,7
         LD,10    S:GJOBACN,5 GET ACCOUNT FOR GHOST
         LCI      2
         STM,10   TSTACK+5+13-J:JIT,7 SET ACCOUNT IN REGS
         STM,10   J:ACCN-J:JIT,7
         B        SI101G
         PAGE
*        DRIVE TABLES FOR LIMIT DEFAULT STORING
LIM      COM,2,6,24 CF(2),AF(1),AF(2)
*        DEFAULT SERVICE LIMITS
LIMLOAD  LW,9     SL:BDF,5
         LW,9     SL:GMX,5          ***TEMP UNTIL GHOSTS
*                                    LOG ON***
         LW,9     SL:ODF,5
*        SYSTEM MAX SERVICE LIMITS
SMLOAD   DATA     SL:BMX
         DATA     SL:GMX
         DATA     SL:OMX
SMSTO    DATA     J:TITLE-J:JIT
         DATA     J:CCBUF-J:JIT
         DATA     J:CCBUF-J:JIT
LIMSTORE STW,9    *7,6
         STB,9    *7,6
         STH,9    *7,6
         BAL,11   0,6
LIMINFO  EQU      %-1
         LIM,WORD 17,ATITLE+19      TIME
         LIM,WORD 17,MPPO           LO
         LIM,WORD 17,MPO            PO
         LIM,WORD 17,MDPO           DO
         LIM,WORD 17,MUPO           UO
         LIM,SPEC 0,PSTST           PSTORE
         LIM,SPEC 0,TSTST           TSTORE
         LIM,BYTE 0,JB:NFPOOL-BA(J:JIT)
         LIM,SPEC 0,TDISK
         LIM,SPEC 0,PDISK
WORD     EQU      0
BYTE     EQU      1
SPEC     EQU      3
PSTST    STW,9    PRDCRM,7
         B        *11
PDISK    RES      0
         STW,9    PRDPRM,7
         B        *11
TSTST    STW,9    TMDCRM,7
         STW,9    TMPDCPK,7
         B        *11
TDISK    RES      0
         STW,9    TMDPRM,7
         STW,9    TMPDPPK,7
         B        *11
*        RESOURCE MAX'S
RMLOAD   DATA     SB:RBMX
         DATA     SB:RGMX
         DATA     SB:ROMX
RMSTO    DATA     JB:CUR-J:JIT
         DATA     JB:MAX-J:JIT
         DATA     JB:MAX-J:JIT
*        RESOURCE DEFAULTS
RDLOAD   DATA     SB:RBDF
         DATA     SB:RGDF
         DATA     SB:RODF
RDSTO    DATA     JB:MAX-J:JIT
         DATA     JB:MAX-J:JIT
         DATA     JB:MAX-J:JIT
         PAGE
SI10NG   BDR,5    SI10GCK
         LD,10    LOGOFF
         LI,4     ONLN              ONLINE
         STW,5    JPUF,7            SET NO PERIPH USE FLAGS
SI101    LCI      2
         STM,10   TSTACK+5+6-J:JIT,7 START UP PROCESSOR
SI101G   STB,4    *7                SET JOB TYPE IN JIT
         SLS,4    -6                0=BATCH,1=GHOST,2=ONLINE
         REF      J:PUF
         LI,R5    BA(J:PUF)-BA(J:JIT)+2
         STB,R1   *R7,R5            USER NUMBER IN JIT
*        STORE MAX'S SERVICE LIMITS
         LI,5     SV:LIM
         LW,3     SMLOAD,4
         LW,6     SMSTO,4
         AW,6     7                 PHY JIT
         LW,9     *3,5
         STW,9    *6,5              SAVE IN JIT
         BDR,5    %-2
*        MAX      RESOURCES
         LW,3     RMLOAD,4
         LW,6     RMSTO,4           WHERE
         AW,6     7                 PHY JIT
         LI,5     SV:RSIZ
         LB,9     *3,5
         STB,9    *6,5
         BDR,5    %-2
*        DEFAULT
         LW,3     RDLOAD,4
         LW,6     RDSTO,4
         AW,6     7
         LI,5     SV:RSIZ
         LB,9     *3,5
         STB,9    *6,5
         BDR,5    %-2
*        PERIPHERAL DEFAULTS
         LW,9     S:SYMDB,4
         REF,2    JH:LDCF
         SLS,9    -16
         LI,3     JH:LDCF-HA(J:JIT)
         STH,9    *7,3
         LI,5     SV:LIM            PUT IN DEFAULT LIMS
SI101L   EXU      LIMLOAD,4         GET NEXT VALUE
         LW,6     LIMINFO,5         GET STORE INFORMATION
         LB,3     6                 SHIFT VALUE & RESOLUTION
         SCS,9    0,3               SHIFT IT
         SLS,3    -6                ONLY RESOLUTION NOW
         EXU      LIMSTORE,3        STORE IT
         BDR,5    SI101L            TO NEXT LIM
         CI,4     2                 ARE WE ONLINE
         BNE      SI1057            NO, DONT SET COCLN
SI1055   LI,2     -1
         AI,2     1
         CB,1     LB:UN,2
         BNE      %-2
         STW,2    M:UC-J:JIT+8,7
SI1057   STS,1    0,7
SI105    EQU      %
*  GET # OF PROCESSORS SWAPPED IN
         LB,1     SB:NP
         BEZ      SI12              NONE
*  RECREATE SHELL CL WHERE DESTROYED BY PROCESSOR TIC
         LI,2     -4
         LI,3     AJFLGS
SIP5     EQU      %
         LW,6     S:ECL,1
         STB,3    *6,2
         BDR,1    SIP5
*  SET UP PROCESSOR'S PP CHAIN HEAD
SIP6     EQU      %
         LB,1     SB:NP             GET # OF PROCESSORS
         LB,3     SB:PNL,1          GET A PROCESSOR #
         LOAD,2   SX:HPP,1          GET PROCS TEMP PP HEAD
         STORE,2  PX:HPP,3          SET HEAD OF PROCS PP CHAIN
         BDR,1    SIP6+1
*  GET IN SWAP USER # & JIT ADR
SI12     EQU      %
         LW,1     S:ISUN            IN SWAP USER #
*  PUT JIT & AJIT PP # IN CMAP
         LOAD,2   UX:JIT,1
         LI,5     JXCMAP
         SLS,5    -:BIG
         AI,5     JJITVP            DISP FROM 0 OF JIT IN CMAP
         STORE,2  *7,5              SET JIT PP IN CMAP
         LH,6     UH:FLG,1
         CI,6     JITIC
         BANZ     %+2
         MTW,-1   S:FPPC
         LW,2     S:AJP
         BEZ      SI125
         LI,5     JXCMAP
         SLS,5    -:BIG
         AI,5     JAJITVP           DISP FROM 0 OF AJIT IN CMAP
         STORE,2  *7,5
         CI,6     JITIC
         BANZ     %+2
         MTW,-1   S:FPPC
*  PUT AJIT'S PP ADR IN JIT & CREATE CL ADR
SI125    EQU      %
         LW,6     S:AJP             AJIT PP #
         STW,6    JAJ,7             PUT INTO JIT
         SLS,6    9                 CL ADR IF IN AJIT
         AI,6     0
         BNEZ     %+3               IF = 0 ,
         LW,6     7                 GET JIT ADR AND
         AI,6     JCL               ADD CL DISP TO IT
* SET CL PHY ADR
         STW,6    JCLPA,7           SET UP CL'S PHY ADR
*  RESTORE  CL WHERE TIC WAS PUT
         LW,8     JCLT,7            SACED CL WORD
         BEZ      SI128
         LW,5     JCLP,7            GET DISP OF TIC FROM CL
         BEZ      SI128
         BGZ      SI127
         EOR,5    Y8
         CI,5     JCCL              IS IT MAX CL IN JIT
         BE       SI128             YES NO NEED TO RESTORE
SI127    EQU      %
         STW,8    *5,6              RESTORE CL
*  MASK PHY DISC ADR POINTER INTO CL IN JIT (OR AJIT)
SI128    LW,5     JCLE,7            GET # OF WDS IN CL
         BEZ      SI13
         LW,8     7                 GET JIT'S (DAT'S) PP #
         LI,0     :BIG
         BEZ      %+2
         LW,8     JCLPA,7           DAT IS IN AJIT PAGE..
         SLS,8    2                 MAKE IT A BA
         LW,14    Y02               READ
         LW,15    YFF
         LW,9     XFFF800           BA PP # MASK
         AW,5     JCLPA,7
         LI,0     3
SI129    AI,5     -2                NEXT CLIST IOCD
         CW,5     6
         BL       SI13              END OF CLIST
         CB,0     *5                IS THIS IOCD A SEEK
         BLE      %+3
         STS,14   *5                NO- STORE READ ORDER
         B        SI129
         STS,8    *5                STORE BA(DISC ADDRESS) FOR SEEK
         B        SI129
SI13     EQU      %
         PAGE
*************************************
*        IF ANY PROCESSORS ARE      *
*        ASSOCIATED, MOVE JIT DA TO *
*        SHELL DA                   *
*        SET PROC DA IN A REG,      *
*        OTHERWISE SET TO 0         *
*        IF DELTA, SET THE ONE DA   *
*************************************
*
*        0  = USER FLAGS
*        2  = INDEX TO 1ST VP LINK
*        3  = # OF ENTRIES IN DA TABLE FOR MOVING JIT'S DA TO SDA
*        4  = PROCESSOR ROOT #
*        5  = ADR OF NEXT DA TABLE ENTRY
*        6  = DA TABLE ADR - 2    FOR MOVING JIT'S DA TO SDA
*        7  = JIT ADR
*        8  = J:LMAP
*        9  = J:CMAP
*        14 = DA FOR PROCESSOR DCB & INIT OR 0 IF NO PROCESSOR
*
*  SET UP SOME REGS FOR THIS SECTION & THE NEXT SECTION
         STD,7    8
         AI,8     JLMAP
         AI,9     JCMAP
         LI,5     SCL%END
         LW,0     M:HLTIC
         STW,0    0,5
         AI,5     -2
         STW,5    TSC3
         LH,0     UH:FLG,1          GET USER FLAGS
         LI,14    0
         LI,15    0
* IF NOT INIT, SKIP DA MOVE
         CI,0     INIT|DCBS         INIT OR DCBS TO BE BROUGHT IN
         BAZ      SIU0              NO
* GET APPRO PROC # AND COMPUTE DISC ADR
         LB,4     UB:ACP,1          GET COMMAND PROC #
         CI,0     TIC
         BANZ     SIP9
         LB,4     UB:APR,1
         BNEZ     SIP9
         LB,4     UB:ASP,1
         CI,0     DELA
         BAZ      %+2
         LB,4     UB:DB,1
SIP9     EQU      %
         LB,13    PB:DCBSZ,4        GET DCB SIZE
*
         CI,0     INIT
         BAZ      %+2               NO INIT
         LB,15    PB:DSZ,4
         AW,15    13
         LI,5     0                 SWAP INDEX
         LH,12    PH:DDA,4
         LB,13    MB:GAM6
         LI,0     %+1
         BDR,15   SADRINC+1         INC DISC ADDRESS...
         STW,12   14
         LH,0     UH:FLG,1
SIP94    EQU      %
         PAGE
*  PREPARE FOR SETTING CMAP, CL & PPUT & PROCESSORS DA IF NEEDED
*        0  = UH:FLG
*        1  = IN SWAP USER #
*        2  = PRES VP #
*        3  = NEW PP #
*        4  = NEXT PP # IN USERS PP CHAIN
*        5  = ADR OF NEXT DA TABLE ENTRY
*        6  = CL ENTRY
*        7  = JIT ADR
*        8  = LMAP ADR
*        9  = CMAP ADR
*        10 = ACCUM TO GET NEXT PPUT LINK
*        12 = PP ADR FOR CL
*        13 = PP ADR MASK
*
SIU0     EQU      %
         LW,13    XFFF800           MASK FOR SELECT STORE PP ADR TO CC
         LW,6     JCLE,7            GET DISP OF CL END FROM CL BEG
         AW,6     JCLPA,7           ADD
         AI,6     -2
         LW,1     7
         SLS,1    2                 BA OF J:JIT
         LW,15    7
         LW,11    JVLCS,7
         LB,7     JVLH,1
         CI,11    X'1FF'
         BE       %+3
         CW,11    7
         BNE      %+2
         LB,11    *8,7
         LI,7     SDA%END
         PAGE
         LW,2     S:ISUN
         CI,0     JITIC
         BANZ     SIU1              JIT IC
*  JIT NOT IN CORE    IS THIS 1ST TIME
         LOAD,3   UX:JIT,2
         LOAD,12  UX:JIT,2
         LW,10    S:JSP
         BNEZ     SIU7              1ST TIME JIT IN
         LB,4     UB:PCT,2
         CI,4     1+:BIG            HOW MANY PAGES
         BE       SIU75             NOT 1ST TIME IN BUT JIT ONLY
*  SET AJIT & JIT IN PP CHAIN TAIL & 0 END
         LW,4     S:AJP
         BEZ      %+4               NO AJIT PP
         MTB,1    JPPC,1
         STORE,3  MX:PPUT,4         LINK AJIT TO JIT
         LW,12    4
         LI,10    0
         STORE,10 MX:PPUT,3         0 TO JIT
         MTB,1    JPPC,1
         SLS,1    -:BIG             NOP OR SHIFT FROM BA TO HA(JIT)
         STORE,3  JPPT,1
*  SET IN 1ST PP OF CHAIN TO GET HEAD CORRECT
         LW,4     S:FPPH            GET 1ST FREE PP
         BEZ      SIO01
         LOAD,10  MX:PPUT,4         SAVE NEXT FREE PP
         STORE,4  JPPH,1            PUT 1ST PP IN PPH
         SLS,1    :BIG              NOP OR SHIFT FROM HA TO BA(JIT)
         STORE,12 MX:PPUT,4         LINK 1ST P TO JIT OR AJIT
         LB,2     JVLH,1           GET 1ST V LINK
         BEZ      SIU8
         LOAD,12  *9,2
         CI,12    NPMC
         BNE      SIU5
         B        SIU2
SIO01    LW,4     S:AJP             NO PAGES TO INSWAP...
         BNEZ     %+2               USE THE AJIT PAGE, OR
         LW,4     3                 THE JIT PAGE, FOR THE HEAD.
         STW,4    S:FPPH
         STORE,4  JPPH,1
         B        SIU12
*  JIT WAS IN BUT IF 1ST PP NOT SET (IE=0) SET HEAD PROPER
SIU1     EQU      %
         LB,2     JVLH,1           GET 1ST V LINK
         BEZ      SIU8
         LW,4     S:FPPH
         LOAD,3   *9,2              GET 1ST CMAP
        CI,3     NPMC
        BNE      SIU6
*  SET 1ST PP
         LOAD,10  MX:PPUT,4         SAVE NEEXT FREE PP
         SLS,1    -:BIG
         LOAD,5   JPPH,1
         STORE,4  JPPH,1
         SLS,1    :BIG
         STORE,5  MX:PPUT,4
*  SET PROC DISC ADR IF PPSWAP SET
SIU2      EQU     %
         CI,0     PPSWAP
         BANZ     %+3
         CI,0     INIT|DCBS
         BAZ      SIU5
         LI,12    SIU5              RET ADDR
         B        S%INIT
         PAGE
SIU3     EQU      %
         LW,3     2
         LB,2     *8,2              GET V LINK
         BEZ      SIU8
         CW,2     11                VLCS
         BE       SIU8
         CI,0     PPSWAP
         BANZ     SIU35
         CI,0     INIT|DCBS
         BAZ      SIU4
         LOAD,12  *9,2              CMAP
        CI,12    NPMC
         BE      SIU35+3
         B        SIU4
SIU35    EQU      %
         LOAD,12  *9,2              CMAP
         CI,12    NPMC
        BNE      SIU6
         BAL,12   S%INIT
SIU4     EQU      %
         LOAD,10  MX:PPUT,4         SAVE NEXT FREE PP
         LOAD,5   *9,3              GET PREV PP FROM CMAP
         LOAD,12  MX:PPUT,5
         STORE,4  MX:PPUT,5         LINK BACK
         STORE,12 MX:PPUT,4         LINK FORE
SIU5     RES      0
         STORE,4  *9,2              CMAP
         MTW,-1   S:FPPC
         LW,12    4                 PP INSERTED
         LW,4     10                NEXT FREE PP
         SLS,12   11
         STS,12   *6                SET PP IN CLIST
         MTB,1    JPPC,1
SIU6     EQU      %
         AI,6     -2                DEC CLIST PTR
         LB,12    *6                TO NEXT ENTRY
         CI,12    3                 CHECK ORDER CODE
         BGE      %-3               SKIP SEEKS
         B        SIU3              AGAIN
SIU7     EQU      %
*  JIT IN FOR 1ST TIME  INCR CNT & SET NASP
         LI,5     JBNASP
         STB,10   *15,5
SIU75    EQU      %
         LI,5     JBPCC
         LI,10    1+:BIG            2 IF BIG 9 OR
         STB,10   *15,5            1 TO CONTEXT COUNT
         SLS,1    -:BIG
         STORE,3  JPPH,1
         LW,4     S:AJP             IF HE HAS AN AJIT FIRST TIME
         BEZ      SIU76
         STORE,3  MX:PPUT,4
         STORE,4  JPPH,1
         LW,2     S:ISUN
         LH,12    UH:JIT,2          AND SETUP JIT AND AJIT
         STH,12   UH:AJIT,2         DISC ADDRESSES...
         LB,5     UB:SWAPI,2
         BAL,0    SADRINC
         STH,12   UH:JIT,2          PUT JIT ON 2ND GRANULE.
SIU76    EQU      %
         STORE,3  JPPT,1
         SLS,1    :BIG
         MTB,1+:BIG  JPPC,1         INCREMEMT BY 2 IF BIG 9
         LI,10    0
         STORE,10 MX:PPUT,3
SIU8     EQU      %
         LW,7     15                SET JIT ADR BACK TO 7
*  INIT VLCS TO LARGEST POSSIBLE P # SINCE IT INDICATES HOW FAR DOWN
*  VIRTUAL CHAIN, CORE IMAGE DOES NOT JIVE WITH DISC IMAGE
         LI,10    X'1FF'
         STW,10   JVLCS,7
*
*  SET UP AJIT IF  - BOTH ITS DA=0 AND, ITS CMAP= FPMC
         LW,2     S:ISUN
         LH,3     UH:AJIT,2
         BNEZ     SIU9              ALREADY HAVE AJIT
         LI,2     JAJITVP
         LOAD,3   *9,2              CMAP
         CI,3     FPMC
         BE       SIU9
*        4  = NEXT FREE PP
         LI,3     JJITVP
         LOAD,5   *9,3              JIT PP IN CMAP
         LB,3     JVLT,1
         LOAD,3   *9,3              LAST PP (LINKED TO JIT PP)
         STORE,4  MX:PPUT,3         LINK LAST TO AJIT
         STORE,5  MX:PPUT,4         LINK AJIT TO JIT
         MTB,1    JPPC,1            UPDATE PP CNT
         STORE,4  *9,2              PUT AJIT PP INTO CMAP
         MTW,-1   S:FPPC
SIU9     EQU      %
*  IS BOTH READY TO RUN RESET AND SWAP PURE P SET - NO I/O, HAD VP NO PP
         LW,2     S:ISUN
         LH,0     UH:FLG,2
         CI,0     INIT|DCBS
         BANZ     SIU10
         CI,0     PPSWAP+JITIC
        BANZ     SIU12
         LB,5     UB:PCT,2
         CI,5     1+:BIG
         BE       SIU12
SIU10    EQU      %
         LW,5     JCLE,7            CL LENGTH
         AW,5     JCLPA,7           LAST CDW+1
         STW,5    TSC1
         LB,1     UB:SWAPI,2        RADX
         LW,10    M:HLTIC,1
         LB,14    UB:SWAPI,2        RADX
         BNE      SIU10A            USER NOT ON SAME RAD
         CI,0     INIT+DCBS
         BAZ      SIU10A            NO INITIAL OR DCBS
         LW,10    TSC3
         AI,10    2                 START OF INIT CL
         SLS,10   -1
         AW,10    Y08               TIC ORDER
SIU10A   EQU      %
         XW,10    0,5
         STW,10   TSC2              SAVE SEEK WORD
         MTW,2    DID%IO            SET SWAP IN I/O FLAG TO 'TRUE'
         DO       PERFORM
         BAL,0    CURNTIM
         STW,1    TSC0
         STW,1    TSC0
         FIN
         LI,1     1
         STW,1    #SWAP%DEV
         LW,6     JCLPA,7
         LI,1     0                 AVOID RESTORING CLIST WORD
         STW,1    JCLT,7            IF NO SWAP OUT OCCURS
         LI,7     4                 READ W/READ CHECK
         LH,0     UH:FLG,2
         CI,0     JITIC
         BANZ     SIU11A            USER IC
         LI,15    SIU11B            RETURN ADDRESS
         CI,0     INIT+DCBS
         BAZ      SIO               USER ONLY
         AI,14    0
         BE       SIO               USER AND INIT ON SAME RAD
         LI,15    SIU11A
         PUSH     15                RETURN IMMEDIATELY
         MTW,1    #SWAP%DEV         2 I/O OPERATIONS
         B        SIO
SIU11A   EQU      %
         LW,6     TSC3
         AI,6     2
         LI,7     2
         LI,14    0
         BAL,15   SIO               SWAP IN INIT&/OR DCBS
SIU11B   EQU      %
*
         DO       PERFORM
         LW,3     TSC0
         PUSH     2,4               RECORD IN SWAP TIME AND TIME FROM
         BAL,4    ISWAP%MEAS2       END OF
         PULL     2,4
         FIN
         LW,10    TSC2              RESTORE SEEK WORD
         STW,10   *TSC1
         LW,1     S:ISUN
         LH,0     UH:FLG2,1
         OR,0     =X'18'            SET JUST SWAPPED IN
         STH,0    UH:FLG2,1         AND DONT SWAP FLAGS
*                                   AFTER PHYSICAL IO ONLY
*
*
*        PLACE SPARE BUFFER PAGES IN WINDOWS
*
         LOAD,2   UX:JIT,1
         SLS,2    9                 PHYS JIT WORD ADDRESS
         LW,5     Y008
         CW,5     JSPBFLG,2         ARE INDICIES IN WINDOW
         BAZ      SIU11C            NO
         LI,4     0                 YES-RESET FLAG
         STS,4    JSPBFLG,2
         SLS,2    2-:BIG            PHYS JIT BYTE/HALFWORD ADR
         LI,4     JXCMAP            BYTE DISPLACEMENT INTO JIT
         SLS,4    -:BIG             B/H DISPLACEMENT INTO JIT
         AW,4     2                 B/H ADDR OF CMAP
         LI,2     JAJITVP+1         INDEX TO 1ST WINDOW PG IN CMAP
         AW,2     4                 B/H ADDR OF 1ST WINDOW PG IN CMAP
         LI,6     JBUPVP-JSBUF1VP   # OF WINDOW PAGES
         LOAD,5   0,2               GET SPARE INDEX FROM WINDOW
         CI,5     FPMC
         BE       %+4               NOTHING MAPPED IN WINDOW
         AW,5     4                 GET B/H ADDR OF SPARE
         LOAD,5   0,5               GET PHYS PG FROM SPARE
         STORE,5  0,2               AND PLACE IN WINDOW
         AI,2     1                 LOOK AT NEXT WINDOW
         BDR,6    %-7
SIU11C   LH,0     UH:FLG,1
         PAGE
SIU12    EQU      %
*  SET UP PROCESSOR'S PP IN CMAP
         LW,1     S:ISUN
         LOAD,7   UX:JIT,1
         SLS,7    11                SHIFT TO BYTE  RESOLUTION
         AI,7     JXCMAP            R7 IS USED IN SPMAP BELOW
         SLS,7    -:BIG             SHIFT TO BYTE OR HALFWORD RES
         LB,2     UB:OV,1
         BAL,4    SPMAP
         CI,0     TIC
         BAZ      SIU121
         LB,2     UB:ACP,1          GET COMMAND PROC #
         B        SIP11
SIU121   EQU      %
         LB,2     UB:APR,1
         BAL,4    SPMAP
         LB,2     UB:APO,1
         BAL,4    SPMAP
         LB,2     UB:DB,1
         CI,0     DIC
         BANZ     SIP11
         LB,2     UB:ASP,1
         BNEZ     SIP11
         LB,2     UB:DB,1
SIP11    EQU      %
         BAL,4    SPMAP
*  SET UB:FLG APROPOS & RESET SWAP IN PROG FLG
         LOAD,2   UX:JIT,1
         SLS,2    11-:BIG
         LOAD,4   JPPH,2
         LOAD,5   JPPT,2
         SLS,2    :BIG              NOP OR SHIFT TO BA(JIT)
         LB,6     JPPC,2
         LI,7     4
         BAL,1    T:PGCHK
       LW,1     S:ISUN
SIU13    EQU      %
         LSETR    JIC,9,1
         RSETS    INIT,9
         RSETS    DCBS,9
         SETST    RTR,9,1
         LB,3     UB:US,1
         LB,5     UB:PRIO,1         GET HIS PRIORITY
         CW,5     S:CUP             IS HE HIGHER THAN CURRENT USER?
         BG       SIU132            NO
         MTW,1    S:HIR             COUNT FOR HIR DUDE
         BG       SIU132            ALREADY GOT SOME
         LI,11    1                 FORCE COUNT TO ONE
         STW,11   S:HIR
SIU132   RES      0
         LW,11    S:FPPC
         BE       SIU135
         SCREECH  X'1B'
SIU135   RES      0
        LI,11    0
        STW,11   S:FPPH
         STW,11   S:FPPT
         DO       DEBUG
         LI,1     9
         BAL,0    RECORD
         FIN
         LI,14    2
SIU14    EQU      %
         LW,0     SL:OPC            GET BASE VALUE FOR OVERLAY PROTECT COUNT
         STW,0    S:OPC             AND RESET WORKING CELL
         LI,0     0
         STW,0    S:ISUN
         DO       PERFORM
         LI,4     TSS2
         LB,1     SB:OSN
         LI,5     CH:DOS
         B        T:DSTRB
         ELSE
         B        TSS2              GO REENTER SS
         FIN
         PAGE
*
*        ERROR READING JIT
*
S:JITERR EQU      %
         LB,2     SB:NP
         BEZ      JE4
*
JE3      EQU      %
         LB,3     SB:PNL,2
         LOAD,8   SX:HPP,2
         STORE,8  PX:HPP,3
         BDR,2    JE3
*
JE4      EQU      %
         LW,4     S:ISUN
         LOAD,6   UX:JIT,4
         LW,7     6
         SLS,7    9
         LI,5     JXCMAP
         SLS,5    -:BIG
         AI,5     JJITVP            DISP TO JIT PG IN CMAP
         STORE,6  *7,5              SET PHY PG IN CMAP
         SLS,7    -1
         LD,12    0PSD
         STD,12   TSTACK-J:JIT,7    INIT TSTACK                      RL3
         LH,8     UH:FLG,4
         CI,8     JITIC
         BANZ     JE45
         MTW,-1   S:FPPC            TAKE JIT OUT OF COUNT
         LW,3     S:AJP             PHY PG # OF AJIT
         BEZ      JE45
         BAL,2    T:FPP             RELEASE IT
         MTW,-1   S:FPPC            AND TAKE IT OUT OF COUNT
JE45     EQU      %
         LW,5     S:FPPH
*
JE5      EQU      %
         LW,3     5
         BEZ      SIU13
         LOAD,5   MX:PPUT,3
         MTW,-1   S:FPPC
         LI,2     JE5
         B        T:FPP             RELEASE USER PAGES
*
         PAGE
*        SET PROC S CORE MAP
SPMAP    EQU      %
         BEZ      SPMAP2O
         LB,6     PB:PVA,2
         AW,6     7
         LOAD,3   PX:HPP,2
         LB,8     PB:PSZ,2
         B        %+2
SPMAP2   EQU      %
         LOAD,3   MX:PPUT,3
         STORE,3  0,6
         AI,6     1
         BDR,8    SPMAP2
SPMAP2O  B        0,4
         PAGE
*        BUILD COMMAND LIST USED TO SWAP IN INIT AND DCBS
*
*
S%INIT   EQU      %
         CI,0     INIT+DCBS
         BAZ      *12
         PUSH     2,12
         STH,14   0,7               SET DA
         LW,12    4
         SLS,12   11
         AW,12    Y02               READ COMMAND
         STW,12   *TSC3
         MTW,-2   TSC3
         LW,12    7
         SLS,12   1
         AW,12    Y03               SEEK ORDR
         STW,12   *TSC3
         REF      Y03
         AI,7     -1
         AI,14    -2
         MTW,-2   TSC3
         LB,12    MB:GAM6
         LW,13    12
         AI,12    -1
         CS,12    14
         BNE      %+2               NOT ON TO NEXT BAND YET
         SW,14    M:ADRINCR
         PULL     2,12
         B        *12
*
         PAGE
*************************************
*        OSAC                       *
*                                   *
*        ORDER                      *
*        SORT                       *
*        AND                        *
*        CHAIN                      *
*************************************
*
*   I    8  = # OF USERS  WHEN 2ND INDEX=(8) THEN ORDERING DONE
*        7  = ORDER # INSERTED IN 1ST HALF OF BDA
*        1  = 1ST INDEX
*        2  = 2ND INDEX
*        9  = SAVES 2ND INDEX TO CONTINUE RIPPLE UP AFTER RIPPLE DOWN
*        10 = PRESENT BDA BEING USED FOR COMPARISON
*        11 = SECTOR MASK USED FOR COMPARE SELECTIVE
*        12 = ACC TO RIPPLE A BDA UP WHEN RIPPLING DOWN
*        15 = SUBROUTINE LINK
*
*  FIRST ORDERING OF LIST
OSAC     EQU      %
         CI,8     1
         BE       OUT1
*  GENERATE ORDER LIST INDEXES
         LW,7     8                 GET NUMBER OF USERS
         AI,7     -1
FO1      EQU      %
         LW,10    S:BDA+1,7
         STH,7    10                PUT INDEX INTO 1ST HALF OF BDA WORD
         STW,10   S:BDA+1,7         PUT BDA BACK
         BDR,7    FO1               CONT
*  GET NEXT ENTRY SET
         LW,2     14
         LB,11    MB:GAM6,2         SECTOR MASK
         LI,2     0
FO2      EQU      %
         LW,1     2                 UPDATE 1ST TO 2ND
         AI,2     1                   '   2ND
         CW,2     8                 2ND INDEX = N
         BE       CCL0
         LW,10    S:BDA+1,1         GET A BDA
*  MAKE RIPPLE UP COMPARISON
         CS,10    S:BDA+1,2         COMPARE WITH NEXT
         BL       FO2               LESS - IN ORDER - CONT
*  RIPPLE BACK DOWN
         LW,9     2                 SAVE 2ND INDEX
         XW,10    S:BDA+1,2         PULL LESSER BDA, PUT GREATER BDA UP
RBD1     EQU      %
         AI,1     -1                FINISH RIPPLE DOWN
         BLZ      RBDF1             YES - RETURN TO RIPPLE UP
         AI,2     -1                  '   2ND   '
         CS,10    S:BDA+1,1         ONE FOUND, STILL OUT OF ORDER
         BG       RBDF2             NO - RETURN  RIPPLE UP
         LW,12    S:BDA+1,1         RIPPLE BDA
         STW,12   S:BDA+1,2
         B        RBD1              CONT RIPPLE BACK DOWN
*  RIPPLE DOWN COMPLETE - RESTORE RIPPLE UP POINTER & CONT
RBDF1    EQU      %
         STW,10   S:BDA+1           INSERT 1 OUT OF ORDER IN 1ST ENTRY
         B        %+2
RBDF2    EQU      %
         STW,10   S:BDA+1,2         INSERT ONE OUT OF ORDER IN
         LW,2     9                 RESTORE 2ND INDEX
         B        FO2               CONT RIPPLE UP
         PAGE
*
*        SORT & CHAIN
*
*   I    8  = # OF USERS
*        7  = # OF USERS STILL TO CHAIN
*        6  = # OF USERS - 1  TEST TO START OVER SEARCH INDEX
*        1  = INDEX TO PRESENT ENTRY
*        2  = INDEX TO SEARCH ENTRY
*        3  = BACK LINK INDEX TO OTHER TABLES
*        4  = PRESENT INDEX TO OTHER TABLES
*        10 = PRES EDA FOR COMPARISON
*        12 = SEARCH F&BL AND BDA
*        13 = MASK TO LOAD SELECTIVELY F&BL AND BDA
*        5  = ADR OF WHERE TO PUT TIC IN CL
*        15 = SUBROUTINE LINK
*
*  CHAIN COMMAND LIST BY SECTOR POSITION
CCL0     EQU      %
         LW,7     8                 GET NUMBER TO SORT AND CHAIN
         CI,7     1                 ONE OR LESS USERS ?
         BLE      OUT1              YES
         LW,13    CHNMSK            GET FLG&BACK LINK & SECTOR MASK
         LW,6     8                 GET OUT SWAP NUMBER
         AI,6     -1                REDUCE BY 1
         LI,2     0                     '      SEARCH      '
         LI,3     0                 BACK LZNK INDEX TO OTHER TABLES
         LH,4     S:BDA+1                PRES   '   '    '     '
*  STORE FLAG & BACK LINK IN BDA
CCL1     EQU      %
         AI,3     X'80'             FLAG
         LW,1     2
         SLS,2    2                 MAKE BYTE INDEX
         STB,3    S:BDA+1,2         SET FPBL
         BDR,7    CCL2              ANY MORE ENTRIES
*  COMPLETED ALL ENTRIES - SET LAST TIC AND F&BL
         LH,1     S:BDA+1
         AND,1    M8                AND F&BL OUT
         LW,10    S:BCL+1,1         GET BCL FOR 1ST ENTRY
         SLS,10   -1
         AW,10    Y08
         LW,5     S:ECL+1,4         FIND END OF CHAIN WHERE TIC BELONGS
         STW,10   0,5               PUT TIC IN CL
         LI,10    X'80'             GET FLG
         AW,10    4                 ADD BACK LINK
         STB,10   S:BDA+1           SET UP F&BL INTO 1ST BDA
OUT1     EQU      %
         B        *15
*  SET UP FOR NEXT SEARCH
CCL2     EQU      %
         LW,1     2                 UPDATE PRES TO SEARCH INDEX
         LW,3     4                 UPDATE PRES INDEX TO TABLES
         AI,4     1
         LH,10    SH:EDA,4          PRES EDA
         LW,2     14
         LB,2     MB:GAM6,2
         AND,10   2
*  INITIALIZE SEARCH INDEX
CCL4     EQU      %
         LI,2     0                 INIT SEARCH INDEX
*  COMPARE NEXT ENTRY
CCL6     EQU      %
         AI,2     1                 INCR SEARCH INDEX
         LS,12    S:BDA+1,2         GET F&BL AND BDA
         CW,10    12                EDA LESS THAN BDA
         BL       CCF               YES - FOUND
*  IF FIRST SEARCH DONE, SET X'C0' IN 1ST BYTE OF EDA
         CW,2     6                 FINISHED 1ST TIME THRU ?
         BNE      CCL6              NO
         AW,10    C0MSK
         B        CCL4              START AT BEG OF LIST
*  FOUND CHAIN, GET INDEX TO OTHERS & SET TIC
CCF      EQU      %
         LW,4     S:BDA+1,2         GET INDEX TO OTHER TABLES
         LH,4     4                 FROM BDA
         LW,10    S:BCL+1,4
         SLS,10   -1
         AW,10    Y08
         LW,5     S:ECL+1,3
         STW,10   0,5               PUT TIC TO (ECL)
         B        CCL1
         PAGE
*************************************
*        ULCLC                      *
*                                   *
*        UNLINK CL CHAIN            *
*************************************
*   I    10 = PRESENT SECTOR POSITION
*   O    5  = POINTS TO END OF CHAIN
*   O    6  = POINTS TO BEG OF CHAIN
ULCLC    EQU      %
*  UNLINK CL CHAIN
         LW,7     TSC4              USER CT
         LW,2     14
         LB,11    MB:GAM6,2
         AI,10    SDLAY
         CW,10    M:GASLIM,2
         BLE      %+2
         AW,10    M:ADRINCR,2
UC2      EQU      %
         CS,10    S:BDA,7           IS PRES SECT POSIT < THIS BDA
         BL       UC4               YES-FOUND
         BDR,7    UC2
         LI,7     1                 NONE LESS - GET FIRST
UC4      EQU      %
         LW,12    S:BDA,7           GET F&BL, INDEX AND BDA
         LB,3     12                GET F&BL - FOR HALT
         AND,3    M7                GET RID OF FLAG, KEEP BACK LINK
         LH,4     12                GET INDEX TO OTHER TABLES - FOR SIO
         AND,4    M8                GET INDEX ONLY
         LW,5     S:ECL+1,3         POINTS TO HALT NEEDED
         LW,6     S:BCL+1,4         ADR OF CL FOR SIO
         B        *15
         PAGE
SADRINC  LB,13    MB:GAM6,5         MAX SECTOR MASK
         AI,12    2                 INC SECTOR ADDRESS
         CS,12    M:GASLIM,5        MAX ALLOWABLE SECTOR #.
         BLE      *0
         AW,12    M:ADRINCR,5       INCREMENT TO NEXT BAND.
         MTB,0    MB:GAM7,5
         BEZ      *0
         AI,12    1                 ODD SECTOR/TRACK
         B        *0
         PAGE
         REF      T:SIO,T:SENSE
SIO      EQU      T:SIO
SENSE    EQU      T:SENSE
         END

