         DEF      AVR:
AVR:     EQU      %
*        704764   SIGMA 5/7         BPM M:AVR
ANSPROC  SET      1
         SYSTEM   UTS
         DEF      AVR
*                 SYMBOLIC REGISTER DEFINITIONS.
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8,SR1   EQU      8
R9,SR2   EQU      9
R10,SR3  EQU      10
R11,SR4  EQU      11
R12,D1   EQU      12
R13,D2   EQU      13
R14,D3   EQU      14
R15,D4   EQU      15
         PAGE
*                 DEFS AND REFS FOR AVR.
         REF      OCQUEUE,NEWQ,GMB,RMB
         REF      MSGOUT,BATAPE
          REF       DOUBLEZERO,AVRTBL,Y2
AVRB     EQU      Y2
         REF      AVRNOU,AVRTBLSIZ,AVRTBLNE
         REF      S:CUN,U:MISC,E:SL,T:REG,GMBSIZ
         REF      Y08,Y04,Y06,Y07,M7,Y1,M16
         REF      ANSFLGS,AVRFNMT
         REF      AVRFLGS
         REF      DCT4
         REF      AVRID
         REF      UB:US
         REF      T:RUE
         REF      SOLICIT
         PAGE
*                 PUB SERIAL NOU AVR ID SOL VER  EXCL
* PREMOUNT PUBLIC  1    #     1   0  0   0   0     -
* PREMOUNT         0    #     0   0  0   0   0     -
* AVAILABLE        0    0     0   0  0   0   0     -
* SOLICITED       1 0   #     #   0  #   1   1     -
* BEING VERIFIED   -    #     0   0  #   0   1     -
* DISMOUNT(LOCK)   1    #     #   1  -1            -
* PRIVATE          0    #     #   1  #   -   -     1
* SHARE            0    #     #   1  0   0   0     -
* EXCL             -    -     -   1  -   -   -     1
* POST-MOUNT       -    #     0   1  0   0   0     0
* PUBLIC           1    #     #   1  0   0   0     0
*
*
*
*
*
*
*
*
*
*
*
         PAGE
AVR      EQU      %
         PUSH     7,R5
         LW,R5    R7
         AI,R5    -BATAPE           AVRX
         MTB,0    SOLICIT,R5        AVR SOLICITED
         BNEZ     AVR1
         LD,R14   AVRTBL,5
         CW,R15   YC1FF
         BANZ     AVRX              BUSY-IGNORE AVR
AVR1     EQU      %
         BAL,SR4  GMB
         BEZ      WAITASEC          NO BUFFER SLEEP
         LW,R6    R14
REAVR    EQU      %
         LD,R0    EAPROG            END ACTION PROGRAM
EAADDRESS STW,R0  GMBSIZ-3,R6
         STW,R1   GMBSIZ-2,R6
         OR,R7    XFF0A00
         LW,R12   Y08               REWIND
         BAL,SR1  POSTAPE
         BAL,SR4  GETFLG1
         BAZ      NOCC              NO CODE CONVERSION ON DRIVE
*                     SET CODE CONVERSION MODE
         LW,R12   L(20**24)
         LW,R15   Y08               EBCDIC
         LB,R14   AVRFLGS,R5
         CI,R14   X'40'
         BAZ      %+2
         LW,R15   Y1                ASCII
         BAL,SR1  POSTAPE1
NOCC     EQU      %
         LI,R12   0                 READ TAPE
         ANLZ,R13 BABUFFER          BYTE ADDRESS BUFFER
         LI,R14   10                COUNT
         BAL,SR1  READTAPE
         CW,R0    Y08               I/O ERROR
         BGE      AVRERROR          YES
         LW,SR4   0,R6              SENTINAL IF ANY
         CW,SR4   VOL1              ANS TAPE
         BE       ANSVOLUME         GOOD SHOW!!!
         CW,11    ASCVOL1
         BE       ASCII             ASCII MODE TAPE
         LB,SR4   ANSFLGS,R5
         AND,SR4  M7
         STB,SR4  ANSFLGS,R5
NOTANSSYS EQU     %
         LW,R12   Y07               FOWARDSPACE FILE
         BAL,SR1  POSTAPE
         LW,R12   Y06               BACKSPACE FILE
         BAL,SR1  POSTAPE
         LW,R12   Y04               BACKSPACE RECORD
         BAL,SR1  POSTAPE
         LW,R12   Y04               BACKSPACE RECORD
         BAL,SR1  POSTAPE
         LI,R12   0                 READ RECORD
         ANLZ,R13 BABUFFER          BYTE ADDRESS BUFFER
         LI,R14   8                 COUNT
         BAL,SR1  READTAPE
         CW,R0    Y08               I/O ERROR
         BGE      AVRERROR          YES
         CW,R0    M16               RBC
         BANZ     AVRERROR          BETTER BE ZERO
LBLVOLUME EQU     %
         LD,R12   *R6               :LBL + SERIAL #
         CW,R12   :LBL              LABEL TAPE
         BNE      AVRERROR
         LW,R14   R6
         BAL,SR4  RMB
         LW,R14   R13               SERIAL #
         LW,R15   AVRB
         LH,R6    AVRID,R5          ID
         BAL,R0   SRCHAVR
AVRX     EQU      %
         PULL     7,R5
         DESTRUCT
*
ASCII    BAL,SR1  GETFLG1
         BAZ      CCERR             ASCII TAPE ON NON-ASCII DRIVE
         LB,14    AVRFLGS,R5
         AI,14    X'40'             SET ASCII
         STB,R14  AVRFLGS,R5
         B        REAVR
*
*
GETFLG1  EQU      %
*                    SET CC ACCORDING TO DRIVE HAS/HASNOT CC
         LW,15    1
         LW,1     5
         AI,1     BATAPE            DCTX
         LB,1     DCT4,1
         LB,14    TB:FLGS1,1
         REF      TB:FLGS1
         LW,1     15                RESTORE R1
         CI,14    X'40'
         B        *SR4
*
CCERR    EQU      %
         LI,R13   ASCIIMSG
         B        PHFT
ANSVOLUME EQU     %
         LB,SR4   ANSFLGS,R5
         OR,SR4   X80
         STB,SR4  ANSFLGS,R5
         ANLZ,R1  BABUFFER
         BAL,SR4  SIXPACK
         LW,R14   R2
         LW,R15   AVRB
         STD,R14  AVRTBL,R5
         LI,R12   0                 READ
         ANLZ,R13 BABUFFER
         LI,R14   80                COUNT
         BAL,SR1  READTAPE
         CW,R0    Y08               I/O ERROR
         BGE      AVRERROR          YES
         CW,R0    M16               RBC
         BANZ     AVRERROR          BETTER BE ZERO
         LW,SR4   0,R6
         CW,SR4   HDR1
         BNE      AVRERROR
         LW,R1    R5
         MI,R1    6*4
         LI,SR4   ANSFNMAX
         ANLZ,R2  BABUFFER
         AI,R2    ANSFNMAX-1
AVR2     EQU      %
         LB,R0    1,R2
         CI,R0    ' '
         BNE      BAAVRFNMT
         AI,R2    -1
         BDR,SR4  AVR2
BAAVRFNMT STB,SR4 AVRFNMT,R1        DO NOT CHANGE THIS LABEL
         ANLZ,R2  BABUFFER
         ANLZ,R3  BAAVRFNMT
         STB,SR4  R3
         AI,R3    1
         MBS,R2   4
         LW,R8    6,R6              VOL SER #
         LW,R9    7,R6              VOL SER # PART TWO
         SLD,R8   24
         BAL,SR4  CNVBIN            CONVERT TO BINARY
         ANLZ,R3  BAAVRFNMT
         AI,R3    18
         STB,R8   0,R3              AVRFNMT (BYTE 18)
         ANLZ,R2  BABUFFER
         ANLZ,R3  BAAVRFNMT
         AW,R3    MVJXPR
         MBS,R2   48                MOVE JULIAN EXPIRATION DATE
         LW,R12   Y04               SKIP RECORD REVERSE
         BAL,SR1  POSTAPE
         LW,R14   R6
         BAL,SR4  RMB               RELEASE MONITOR BUFFER
         LI,SR4   0
         STB,SR4  SOLICIT,R5
         BAL,SR4  WAKEUP
         B        AVRX
AVRERROR EQU      %
         PSW,6    TSTACK
         LW,R1    R5
         LH,R14   AVRID,R5
         BNEZ     AVRERR1           DONT ZAP IF OTHER USER NOW HAS
         LW,R12   Y08               REWIND
         BAL,SR1  POSTAPE
         LW,R12   Y04               THIS 'NOP' IS TO BLOCK USER
         BAL,SR1  POSTAPE           WHILE REWIND IS OUTSTANDING
         LW,R1    R5                AVRX
         LD,R14   DOUBLEZERO
         LH,R6    AVRID,R5
         BAL,R0   SETNEW
AVRERR1  EQU      %
         AI,R1    BATAPE
         LI,3     1                 PRIORITY
         LI,13    AVRERRMSG
         BAL,R5   MSGOUT
         PLW,R14  TSTACK
         BAL,SR4  RMB               RELEASE MONITOR BUFFER
         B        AVRX
AVRERRMSG TEXTC   ' AVR ERROR'
POSTAPE  EQU      %
         LI,R15   1                 #RECORDS
POSTAPE1 EQU      %
         LI,R13   0                 D,C,BUF
         LI,R14   0                 -,SIZE
READTAPE EQU      %
         OR,R12   R7
         ANLZ,R0  EAADDRESS         END ACTION ADDRESS
         BAL,SR4  NEWQ
         B        DEVICEDOWN
         LW,R0    GMBSIZ-1,R6
         B        *SR1
*
BABUFFER MTB,0    *R6
         BOUND    8
EAPROG   STW,12   GMBSIZ-1,R6
         B        *SR4
CNVBIN   EQU      %
         LI,R3    0
CNVBIN0  EQU      %
         LB,R4    R8                EBCDIC DIGIT
         BEZ      CNVBINX           DONE ON ZERO
         AI,R4    -'0'              STRIP ZONE
         MI,R3    10
         AW,R3    R4
         SLS,R8   8                 POSITION NEXT DIGIT
         B        CNVBIN0
CNVBINX  EQU      %
         STW,R3   R8
         B        *SR4
SIXPACK  EQU      %
         PUSH     3,R3
         LI,R5    0
         LI,R4    6
SIXPACK1 EQU      %
         LB,R3    1,R1
         AI,R1    1
         SLS,R3   26
         SLD,R2   2
         SLS,R3   -28
         MI,R5    10
         AW,R5    R3
         BDR,R4   SIXPACK1
         SLS,R2   20
         OR,R2    R5
         PULL     3,R3
         B        *SR4
WAITASEC EQU      %
         LI,R6    1                 WAIT 1 UNIT
         LW,R2    S:CUN             CURRENT USER
         STW,R6   U:MISC,R2
         LI,R6    E:SL
         BAL,SR4  T:REG
         B        AVR1
DEVICEDOWN EQU    %
         LI,R13   DEVICEMSG
PHFT     EQU      %
         LW,R1    R5
         AI,R1    BATAPE
         LI,R3    1                 PRIORTY
         BAL,R5   MSGOUT
         B        AVRX
*
ASCVOL1   DATA    X'564F4C31'       ASCII VOL1
ASCIIMSG TEXTC    'ASCII TAPE'
DEVICEMSG TEXTC   ' DEVICE DOWN'
*
NOTUNIQUE TEXTC   ' NOT UNIQUE'
         PAGE
*                 BAL,0             SRCHAVR
* LOOK FOR MATCHING SERIAL NUMBERS
*        WAKE UP MATCHING USER IF ASLEEP  SET TABLE
*
*        R6       = ID/USER #
*        D4       =  FLAGS
*        D3       =  SERIAL #  AS SPEC.
*        R5       =  AVRX
*                 SEARCH  FOR  MATCH
*
SRCHAVR  LW,1     5                 SEARCH  AVRTABLE FOR MATCH
         LW,D1    D3
         CW,D4    Y1
         BAZ      %+2               NOT SCRATCH
         LI,D3    -1                SEARCH FO -1
         LI,4     0
         LI,D2    AVRTBLSIZ+AVRTBLSIZ END
         CI,1     AVRTBLSIZ         TAPE ?
         BL       CHK
         LI,4     AVRTBLSIZ+AVRTBLSIZ PACK START
         LI,D2    AVRTBLNE+AVRTBLNE END
CHK      CW,D3    AVRTBL,4          REEL : REEL
         BNE      RNE
         SLS,4   -1                 /2
         LD,R2    AVRTBL,4
         REF      YC1FF
         REF      X1000FFFF
         CW,3     YC1FF             BUSY
         BANZ     AVRS
         LH,5     AVRNOU,4          IN USE
         BGZ      AVRS              AVRNOU SOMETIMES NEG. FOR TAPE
         LH,6     AVRID,1           WAKE UP OLD  IF ONE
         BEZ      CHK1
         LH,11    AVRID,4
         BEZ      CHK1
         CW,6     11
         BE       CHK1
         LD,2     AVRTBL,1
         CW,14    2
         BE       AVRS
CHK1     EQU      %
         BAL,11   WAKEUP
         LW,14    12
         LD,12    AVRTBL,4
         INT,13   13     KILL PUB,SCR ETC. , PRESERVE HGP
         LI,12    0
         LH,6     AVRID,4
         STD,D1   AVRTBL,4
         STH,D1   AVRID,4
         STB,D1   SOLICIT,4
         STH,R6   AVRID,R1          SET NEW FORM OLD
*        ENTRY POINT                ENTRY POINT
*        R1 = AVRX
*        R6 = USER #
*        D4 = FLAGS
SETNEW   LI,D2    0
         STB,D2   SOLICIT,1
         STD,D3   AVRTBL,1          SET  NEW  FROM OLD   6=ID
OUT      BAL,11   WAKEUP            NEW -IF ONE
         B        *0                EXIT
         SPACE    2
RNE      RES
         AI,4     2
         CW,4     D2
         BL       CHK                  MORE
         LW,14    12
         STH,R6   AVRID,1           ZAAP OR SET AVRID
         AND,D4   X1000FFFF
         B        SETNEW            WAKE UP
         SPACE    2
AVRS     EQU      %
         AI,R1    BATAPE            DCTX
         LI,R3    1                 PRIORITY
         LI,R13   NOTUNIQUE         MESSSAGE ADDRESS
         BAL,R5   MSGOUT            TYPE ON OC
         B        *0                GO TO KEYIN
*
         PAGE
*                                   ENTER ON 11
WAKEUP   LW,5     6                 6=ID
         BEZ      *11               NONE
         REF      SMUIS
         CI,5     SMUIS
         BG       *11               PREMOUNT
         REF      E:WU
         PUSH     0,5
         DISABLE
         LB,7     UB:US,5
         REF      SW
         CI,7     SW
         BNE      WUX               BAD STATE TO WAKEUP
         LI,6     E:WU              WAKE UP EVENT
         BAL,11   T:RUE             WAKE UP
WUX      ENABLE
         PULL     0,5
         B        *11
VOL1     TEXT     'VOL1'
HDR1     TEXT     'HDR1'
:LBL     TEXT     ':LBL'
XFF0A00  DATA     X'FF0A00'
MVJXPR   GEN,8,24 5,19
         END

