*M*      TICINIT  INITIALIZATION SEGMENT OF TIC MODULE OF TP
         TITLE    'TIC - INITIALIZATION'
*P*  NAME:        TICINIT
*P*  PURPOSE:     SERVES AS INITIALIZATION SEGMENT FOR TERMINAL
*P*               INTERFACE CONTROLLER (TIC) OF TP.
*P*  DESCRIPTION: TICINIT (1)CREATES THE INTERNAL VERSIONS OF THE
*P*               STATION NAMES FILE, THE DELIVERIES FILE, AND THE TFDS
*P*               FILE FROM THEIR EXTERNAL COUNTERPARTS, (2)ASCERTAINS
*P*               THE CHARACTERISTICS OF THE STATIONS CONNECTED TO THE
*P*               TIC, AND (3)BUILDS AND INITIALIZES TABLES WHICH RESIDE
*P*               IN DYNAMIC SPACE.
*P*  REFERENCE    CP-V TP REFERENCE MANUAL, 90 31 12
         SYSTEM   SIG7
         SYSTEM   TPPROCS
:ID,:IB0,:IB1 M:PT 1                SET PT 1 FOR SYSTEM BPM FPTS
*
         DEF      :IB0              TICINIT BPM PT 0 CSECT
         DEF      :IB1              TICINIT BPM PT 1 CSECT
         DEF      :ID               TICINIT DATA
         DEF      :IP               TICINIT PROCEDURE
         SYSTEM   TICPROCS
         PAGE                                                           TIC00530
*        REGISTER UTILIZATION BY THE TIC                                TIC00540
*                                                                       TIC00550
*        THE TIC-EXECUTIVE 'OWNS' THREE REGISTERS, NAMELY               TIC00560
*        REGISTERS ONE, TWO, AND THREE.  THEY ARE EQU'ED BELOW.         TIC00570
*                                                                       TIC00580
*        TIC-TASKS SHOULD NOT USE THESE REGISTERS.                      TIC00590
*                                                                       TIC00600
*        REGISTER '#DEV' CONTAINS THE LOGICAL DEVICE NUMBER             TIC00610
*        THAT THE TIC-TASK IS WORKING ON.  SEVERAL PROCEDURES           TIC00620
*        (E.G. #T#GET) ASSUME THAT IT IS CORRECT!                       TIC00630
*                                                                       TIC00640
#DEV     EQU       1                                                    TIC00650
#ARG     EQU       2                   ARGUMENT TO PROC REGISTER        TIC00670
#BAL     EQU       3                   REGISTER WE BAL ON INTO TIC EXEC TIC00680
#OWN     EQU       4                   REG THAT POINTS TO SUB LOCAL STORTIC00690
*
         PAGE
*
*
*
         REF      #TIC#INT          ENTRY POINT; WORD; USED IN M:INT
*,*  CAL TO SPECIFY WHERE OPERATOR INTERRUPTS & ATTN CHAR ACTIVATION
*,*  ARE TO BE HANDLED
         REF      #HIDE#DWS         ENTRY POINT; WORD; USED TO PUT
*,*                                 WORDS INTO THE FREE SPACE CHAIN
         REF      INITTFDNEXTBUF4WA OUTPUT; WORD; USED TO KEEP TRACK OF
*,*  WHERE WE ARE IN THE INITBUF4 OUTPUT BUFFER
         REF      F:TFDX            INPUT; WORD; DCB USED FOR
*,*                                 TRANSACTION FORMAT DESCRIPTOR FILE
         REF      INITTFDNTH        OUTPUT; WORD; USED TO
*,*  COUNT THE NO. OF TFD RECORDS
         REF      INITTFDTFDFWA     OUTPUT; WORD; USED TO
*,*                                 POINT TO TFD RECORD
         REF      INITTFDPRIMFWA    OUTPUT; WORD USED TO
*,*  POINT TO 1ST WORD OF CURRENT PRIMITIVE
         REF      #FIND#DWS         ENTRY POINT; USED TO OBTAIN
*,*  SPACE FROM THE FREE SPACE CHAIN
         REF      #TIC#STACK        TIC'S TEMP STACK
         REF      #TFDI#GRANULE#KEY#CHAIN INPUT; WORD; USED TO
*,*  POINT TO START OF INTERNAL CHAIN OF TFD'S
         REF      F:TICI            INPUT; WORD; DCB USED TO WRITE
*,*  OUT INTERNAL VERSION OF TFD FILE
         REF      F:STAX            INPUT; WORD; DCB USED FOR STATION
*,*                                 NAMES FILE
         REF      F:STAK            INPUT; WORD; DCB USED FOR
*,*  WRITING OUT INTERNAL VERSION OF STATION NAMES FILE
         REF      INITSTANTH        OUTPUT; WORD; USED TO
*,*                                 COUNT STATION NAMES FILE RECORDS
         REF      #STAI#GRANULE#KEY#CHAIN INPUT; WORD; USED TO
*,*  POINT TO START OF INTERNAL CHAIN OF STATION NAMES
         REF      F:DELX            INPUT; WORD; DCB USED FOR
*,*                                 DELIVERIES FILE
         REF      #DELI#GRANULE#KEY#CHAIN INPUT; WORD; USED TO
*,*  POINT TO START OF INTERNAL CHAIN OF STATION NAMES
         REF      M:SI              INPUT; WORD; DCB USED TO
*,*                                 READ ACQUIRE/TABLE DATA
         REF      M:DO              OPEN M:DO
         REF      F:MYSI            OUTPUT; WORD; DCB USED FOR
*,*  WRITING OUT INTERNAL VERSION OF ACQUIRE/TABLE DATA
         REF      #BIGGEST#MDL#TASK OUTPUT; WORD; USED TO HOLD
*,*  TASK NO. OF BIGGEST MDL-TASK WE HAVE
         REF      #DEV#RECORD#BA#IW INPUT; USED TO INITIALIZE
*,*                                 BUFFERS FOR DEVICE I/O
         REF      #DEV#RECORD#LENGTH#IW  INPUT; USED TO INITIALIZE
*,*  LENGTH OF THE RECORD IN THE BUFFER POINTED TO BY #DEV#RECORD#BA
         REF      #DEV#RECORD#STATUS#IW INPUT; USED TO INITIALIZE
*,*  STATUS BITS WHICH INDICATE ERRORS IN THE STATION'S DEVICE I/O
         REF      #DEV#EVENT#PTR#IW  INPUT; USED TO INITIALIZE
*,*  AN ECB WHICH IS WAITED ON BY THE #WAIT#ON#DEVICE PROT
         REF      #DEV#DCB#POINTER#IW  INPUT; USED TO INITIALIZE
*,*  THE TABLE OF DCBS ASSOCIATED WITH A STATION OR LINE
         REF      #DEV#CURRENT#IO#IW  INPUT; USED TO INITIALIZE
*,*  THE CURRENT DEVICE I/O INDICATORS OF A STATION
         REF      #DEV#INPUT#TRL#IW  INPUT; INITIALIZED FROM
*,*  INFORMATION ON ACQUIRE DATA RECORDS; ALSO USED IN SETTING
*,*  UP I/O BUFFERING
         REF      #DEV#OUTPUT#TRL#IW  INPUT; INITIALIZED FROM
*,*  INFORMATION ON ACQUIRE DATA RECORDS; ALSO USED IN CREATING
*,*  OUTPUT BUFFERS OF THE PROPER LENGTH
         REF      #MDL#WAKEUP#ECB#IW  INPUT; USED TO INITIALIZE
*,*                                 AN ECB FOR EACH MDL-TASK
         REF      #MDL#FIXED#BUFFERS#IW INPUT; USED TO INITIALIZE
*,*                                 UNDYNAMIC MDL BUFFERS
         REF      #MDL#TASK#ORDER#IW POINTER TO ARRAY TABLE OF
*,*                                 MDL TRAMSMISSION SEQUENCING DATA
         REF      #INIT#PRE#SECTION INPUT; WORK SPACE
         REF      ZEROANDNINE       CONSTANTS
         REF      INITGRANULE       OUTPUT; USED TO KEEP TRACK OF
*,*                                 GRANULE NO. FOR F:TICI
         REF      INITCOUNTING      INPUT, OUTPUT; FLAG; >0 IF
*,*                                 COUNTING GRANULES
         REF      INITDELNTH        OUTPUT; RECORD COUNT FOR F:DELX
         REF      #TIC#BEGIN        ENTRY POINT IN TICROOT; WHERE
*,*  WE GO WHEN INITIALIZATION IF DONE
         REF      TICINTOPERATORLATER INTPU, OUTPUT; FLAG USED TO
*,*  TELL IF OPERATOR INPUT IS CURRENTLY ALLOWED; 0=ALLOWED, 1=LATER
         REF      ECBLISTMAXSIZE    OUTPUT; INITIALIZES MAX NO. OF ECBS
         REF      ECBLISTWA         OUTPUT; INITIALIZES ADDR OF WHERE
*,*                                 TO BUILD ECB LIST
         DO       HOWMANYXMITSBREAK>1
         REF      #DEV#XMIT#COUNT#IW  INPUT; USED TO RESERVE AND
*,*  INITIALIZE THE TABLE OF XMIT/BREAK COUNTS
         FIN
         REF      #LINE#UNACQUIRED  CONSTANT USED TO TEST LINE STATUS
         REF      #LINE#CANNOT#INPUT  CONSTANT USED TO TEST LINE STATUS
         REF      #LINE#CANNOT#OUTPUT CONSTANT USED TO TEST LINE STATUS
         SREF     M:EO
         SREF     M:EI
         REF      #BIGGEST#TIC#TASK OUTPUT; USED TO SET TOP TASK NO.
         REF      #DCB#SREFS
         REF      #DCB#SREFS#WLIST
         REF      COCLINEABN        ENTRY POINT; USED FOR ABN I/O
         REF      COCLINEERR        ENTRY POINT; USED FOR I/O ERROR
         REF      MOCLINEABN        ENTRY POINT; USED FOR ABN I/O
         REF      MOCLINEERR        ENTRY POINT; USED FOR I/O ERROR
         REF      #DCB#TABLE#IW     INPUT; USED TO INITIALIZE TABLE
*,*                                 OF DCB ADDRESSES
         REF      #DEV#COMMAND#LINE#RECORD#BA#IW  INPUT; USED TO
*,*  INITIALIZE ARRAY TABLE OF DYNAMIC STORAGE POINTERS TO BUFFERS
*,*  CONTAINING CURRENT 'COMMAND LINE'
         REF      #DEV#COMMAND#LINE#RECORD#LENGTH#IW  INPUT; USED TO
*,*  INITIALIZE ARRAY TABLE OF LENGTHS OF CURRENT 'COMMAND LINES'
         REF      #DEV#ECB#IW       INPUT; USED TO INITIALIZE ARRAY
*,*                                 TABLE OF POSSIBLE ECBS
         REF      #DEV#LINE#IDENTIFIER#IW  INPUT; USED TO INITIALIZE
*,*  ARRAY TABLE OF LINE IDENTIFICATION OF STATIONS
         REF      #DEV#LINE#STATUS#BITS#IW INPUT; USED TO INITIALIZE
*,*  ARRAY TABLE OF BITS/FLAGS CONCERNING WHAT STATIONS ARE DOING
         REF      #DEV#LOGON#BLOCK#IW  INPUT; USED TO INITIALIZE
*,*  ARRAY TABLE OF STRUCTURE-TYPE ENTRIES FOR LOGGED ON STATIONS
         REF      #DEV#MULTIPOINT#INDEX#IW  INPUT; USED TO INITIALIZE
*,*  ARRAY TABLE OF M:LIST INDICES OF STATIONS OR LINES
         REF      #DEV#REGULATION#IW  INPUT; USED TO INITIALIZE ARRAY
*,*  TABLE OF BITS INDICATING WHAT FUNCTIONS HAVE BEEN REGULATED
*,*  OFF BY THE OPERATOR
         REF      #DEV#TYPE#INDEX#UNIT#RECORD INPUT; USED FOR
*,*                                 OBTAINING UNIT RECORD INDEX
         REF      #DEV#TYPE#INDEX#IW INPUT; USED TO INITIALIZE ARRAY
*,*  TABLE CONTAINING TYPE NOS. FOR TERMINALS
         DO       DO#CHECKOUT
         REF      #SNAP#CODE        ENTRY POINT USED BY #SNAP PROC
         FIN
         REF      MBS678CODE        ENTRY POINT USED BY MBS678 PROC
         REF      FIELD6789POINTTOSTRINGCODE ENTRY POINT USED BY
*,*                                 FIELD6789POINTTOSTRING PROC
         REF      FIELD6789LOADAAAACODE  ENTRY POINT USED BY
*,*                                 FIELD6789LOADAAAA PROC
         REF      #TYPE89#CODE      ENTRY POINT USED BY #TYPE89 PROC
         REF      #DEV#STATION#TYPE#IW  INPUT; USED TO INITIALIZE
*,*  ARRAY TABLE OF 2-CHAR. STATION TYPES
         DO       DO#3270
         REF      #DEV#PLATEN#R#IW  INPUT; USED TO INITIALIZE ARRAY TABLE
*,*                                 OF MAX ROWS
         REF      #DEV#PLATEN#C#IW  INPUT; USED TO INITIALIZE ARRAY TABLE
*,*                                 OF MAX COLS
         REF      #DEV#TC#RETRY#IW  INPUT; USED TO ACCESS ARRAY TABLE
*,*  OF RETRY COUNTS FOR TC/BCC ERRORS FOR 3275 STATIONS
         FIN
         DEF      #TIC#INITIALIZE   STARTING LOCATION FOR TIC
         REF      #DEV#MDL#RETRY#IW  INPUT; USED TO ACCESS ARRAY TABLE
*,*  OF RETRY COUNTS FOR MDL STATIONS
         PAGE
*        TIC TABLE NAMES ARE DEFINED WITH LISTS FOR                     TIC00710
*        FLEXIBLIITY.  FOR NOW, THE LIST CONSISTS OF THE                TIC00720
*        ADDRESS OF THE INDIRECT WORD THAT POINTS TO THE                TIC00730
*        TABLE AND THE LENGTH OF A TABLE ENTRY IN BYTES.                TIC00740
*                                                                       TIC00750
#DEV#RECORD#BA SET #DEV#RECORD#BA#IW,4                                  TIC00760
#DEV#RECORD#LENGTH SET #DEV#RECORD#LENGTH#IW,4                          TIC00780
#DEV#RECORD#STATUS SET #DEV#RECORD#STATUS#IW,4                          TIC00800
#DEV#EVENT#PTR SET #DEV#EVENT#PTR#IW,4                                  TIC00810
*                                                                       TIC00830
#DEV#DCB#POINTER SET #DEV#DCB#POINTER#IW,2                              TIC00840
#DEV#CURRENT#IO SET #DEV#CURRENT#IO#IW,1                                TIC00850
#DEV#INPUT#TRL SET #DEV#INPUT#TRL#IW,2                                  TIC00860
#DEV#OUTPUT#TRL SET #DEV#OUTPUT#TRL#IW,2                                TIC00870
#DEV#MDL#RETRY  SET  #DEV#MDL#RETRY#IW,1
*                                                                       TIC00880
#MDL#WAKEUP#ECB              SET       #MDL#WAKEUP#ECB#IW,8             TIC00890
         DO        DO#FIXEDMDLBUFFERS
#MDL#FIXED#BUFFERS SET #MDL#FIXED#BUFFERS#IW,4
         FIN
*
#MDL#TASK#ORDER SET #MDL#TASK#ORDER#IW,4
*                                                                       TIC00910
#DEV#COMMAND#LINE#RECORD#BA SET #DEV#COMMAND#LINE#RECORD#BA#IW,4        TIC00920
#DEV#COMMAND#LINE#RECORD#LENGTH SET #DEV#COMMAND#LINE#RECORD#LENGTH#IW,2TIC00930
*                                                                       TIC00940
#DEV#LINE#IDENTIFIER         SET       #DEV#LINE#IDENTIFIER#IW,4        TIC00950
#DEV#MULTIPOINT#INDEX        SET       #DEV#MULTIPOINT#INDEX#IW,1       TIC00960
*
#DEV#LINE#STATUS#BITS        SET       #DEV#LINE#STATUS#BITS#IW,2
#LINE#SWITCHABLE EQU 1024
#LINE#SWITCH#DONT EQU 2048
*
#DEV#REGULATION    SET #DEV#REGULATION#IW,1                             TIC00980
*
#DEV#TYPE#INDEX    SET       #DEV#TYPE#INDEX#IW,1
*                                                                       TIC00990
#DEV#STATION#TYPE SET #DEV#STATION#TYPE#IW,2                            TIC01000
*                                                                       TIC01010
         DO       DO#3270
#DEV#PLATEN#R  SET  #DEV#PLATEN#R#IW,1
#DEV#PLATEN#C  SET  #DEV#PLATEN#C#IW,1
#DEV#TC#RETRY  SET  #DEV#TC#RETRY#IW,1
         FIN
         DO        HOWMANYXMITSBREAK>1
#DEV#XMIT#COUNT    SET       #DEV#XMIT#COUNT#IW,1
         FIN
*
#DEV#ECB SET        #DEV#ECB#IW,8                                       TIC01020
*                                                                       TIC01021
*                                                                       TIC01022
*                                                                       TIC01023
#DCB#TABLE                   SET       #DCB#TABLE#IW,4                  TIC01024
*                                                                       TIC01030
*                                                                       TIC01040
*                                                                       TIC01050
#DEV#LOGON#BLOCK SET #DEV#LOGON#BLOCK#IW,4,0                            TIC01060
*                                                                       TIC01070
*        THE FOLLOWING FIELDS ARE IN THE BLOCK                          TIC01080
*        POINTED TO BY THE ABOVE.                                       TIC01090
*                                                                       TIC01100
#DEV#GET#LIST#LENGTH SET #DEV#LOGON#BLOCK#IW,4,3,4                      TIC01110
#DEV#DMODE         SET #DEV#LOGON#BLOCK#IW,4,0,1                        TIC01120
#DEV#USING#TFD     SET #DEV#LOGON#BLOCK#IW,4,1,4                        TIC01130
#DEV#DOING         SET #DEV#LOGON#BLOCK#IW,4,1,1                        TIC01140
#DEV#GET#LIST#ID   SET #DEV#LOGON#BLOCK#IW,4,1,2                        TIC01150
#DEV#DOLLARS#LAL   SET #DEV#LOGON#BLOCK#IW,4,4,4                        TIC01160
#DEV#QUESTIONS#LAL SET #DEV#LOGON#BLOCK#IW,4,5,4                        TIC01170
#DEV#AT#NAME#LAL     SET #DEV#LOGON#BLOCK#IW,4,6,4                      TIC01180
#DEV#CRUNCH#NAME#LALS SET #DEV#LOGON#BLOCK#IW,4,7,4                     TIC01190
*                                                                       TIC75240
INITBUF2 EQU       X'10000'            DEFINE INITIALIZATION
INITBUF3 EQU       X'10200'             BUFFERS AS FOUR M:GVP-ABLE
INITBUF4 EQU       X'10400'              PAGES OUT IN THE BOONDOCKS.
INITBUF5 EQU       X'10600'
         PAGE                                                           TIC35520
*                                                                       TIC35530
*        DEFINE PRIM NUMBERS FOR THE VARIOUS PRIMITIVES.                TIC35540
*                                                                       TIC35550
UPJ      CNAME                                                          TIC35560
         PROC                                                           TIC35570
I        DO        NUM(AF)                                              TIC35580
AF(I)    SET       J                                                    TIC35590
J        SET       J+1                                                  TIC35600
         FIN                                                            TIC35610
         PEND                                                           TIC35620
*                                                                       TIC35630
J        SET       1                                                    TIC35640
*                                                                       TIC35650
         UPJ       TFDZ,TFDA,TFDB,TFDC,TFDD,TFDE                        TIC35660
         UPJ       TFDF,TFDG,TFDI,TFDJ,TFDK,TFDL                        TIC35670
         UPJ       TFDM,TFDP,TFD@,TFD#,TFDX,TFDY                        TIC35680
         PAGE
         USECT    :ID               GO TO TICINIT DATA SECTION
DUMMYBUF ;
         RES      1                 DUMMY BUFFER FOR KEYED POSITIONING READ
:IP      CSECT    1                 TICINIT PROCEDURE SECTION
OPNDO20  LB,5     10                L/OPEN ERR/ABN CODE
         CI,5     X'03'             C/CODE W/3; FILE DOESN'T EXIST
         BNE      OPNDO60           B/NOT FILE-DOESN'T-EXIST
         M:OPEN   M:DO,(OUT),(SAVE),(CONSEC),;
                  (ERR,OPNDO60),(ABN,OPNDO60)
         M:CLOSE  M:DO,(SAVE)
         M:OPEN   M:DO,(INOUT),(ABN,OPNDO60),(ERR,OPNDO60)
         B        OPNDO90
OPNDO60  M:OPEN   M:DO,(OUT),(DEVICE,'LP')
         #SNAP,31 'PROBLEM OPENING M:DO'
         B        OPNDO95
#TIC#INITIALIZE RES 0
         M:INT     #TIC#INT            HANDLE OPERATOR INTERRUPTS.
*
         M:OPEN   M:DO,(INOUT),(ABN,OPNDO20),(ERR,OPNDO20)
OPNDO90  M:PFIL   M:DO,(EOF)        SKIP TO END OF FILE
OPNDO95  EQU      %
*
         M:SETDCB M:DO,(ERR,0),(ABN,0) RESET ERR & ABN ON M:DO
         #SNAP,10 'ENTERING TIC INITIALIZATION'
*
*        GET THE PAGES THAT WILL BE USED AS
*        BUFFERS BY THE INITIALIZATION SECTION:
*
         M:GVP     INITBUF2
         BCS,8     INITNOPAGES
         M:GVP     INITBUF3
         BCS,8     INITNOPAGES
         M:GVP     INITBUF4
         BCS,8     INITNOPAGES
         M:GVP     INITBUF5
         BCS,8     INITNOPAGES
         LI,4     DA(#INIT#PRE#SECTION)  GIVE INITIALIZATION
         LI,5     100/2                   SOME SPACE TO WORK IN
         BAL,#BAL #HIDE#DWS                (HOPEFULLY AVOIDS AN EARLY
*                                           PAGE-GRAB SOLELY FOR
*                                            INITIALIZE STUFF)
         PAGE                                                           TIC75280
*                                                                       TIC75290
*                                                                       TIC75300
*
*        WE PUT ALL OF OUR INTERNAL-FORMAT RECORDS INTO
*        ONE FILE.  IN ORDER TO FIND OUT HOW BIG THIS FILE
*        SHOULD BE, WE MUST SCAN THE SUPPLIED EXTERNAL-FORMAT
*        FILES IN ORDER TO SEE HOW MANY INTERNAL-FORMAT
*        GRANULES THE INFORMATION WILL FIT INTO.
*
*        CURRENTLY, WE ONLY SCAN THE TFDX FILE, ASSUMING THAT
*        THE STAX AND DELX INFO WILL FIT INTO 40 GRANULES.
*
*        THE DATA CELL 'INITCOUNTING' IS ASSEMBLED AS A ONE
*        TO INDICATE THAT WE ARE JUST COUNTING GRANULE USAGE.
*
INITTFD110 RES     0                   COUNT OR COPY TFD RECORDS.
         LI,11     INITBUF4            INDICATE THE OUTPUT
         STW,11    INITTFDNEXTBUF4WA    BUFFER IS EMPTY.
*                                                                       TIC75440
INITTFD200 RES     0                                                    TIC75450
*                                                                       TIC75460
*        GET A RECORD:                                                  TIC75470
         M:READ    F:TFDX,(BUF,INITBUF2),(SIZE,2047)                    TIC75480
         M:CHECK   F:TFDX,(ERR,INITTFDERR),(ABN,INITTFDABN)             TIC75490
*                                                                       TIC75500
         MTW,1     INITTFDNTH          BUMP OUR RECORD COUNT            TIC75510
*                                                                       TIC75520
         LW,7      F:TFDX+4            GET 'ACTUAL RECORD SIZE'         TIC75530
         SLS,7     -17                  AND ALIGN IT.                   TIC75540
*                                                                       TIC75550
         CI,7      17                  SEE IF RECORD UNREASONABLY SHORT.TIC75560
         BLE       INITTFDBAD          OUT IF SO.                       TIC75570
*                                                                       TIC75580
         LI,8      0                   STORE A ZERO AS A 'FENCE'        TIC75590
         STB,8     INITBUF2,7           IN THE INPUT BUFFER.            TIC75600
*                                                                       TIC75610
         LI,8      4*INITBUF2          POINT R8 AT KEY.
         LI,9      4*INITBUF3+4        POINT R9 TO WHERE KEY SHOULD
         OR,9      =X'11000000'         GO (WITH THE SEVENTEEN COUNT).  TIC75640
         MBS,8     0                   MOVE 'KEY' TO OUTPUT BUFFER.     TIC75650
*                                                                       TIC75660
         LI,10     INITBUF3
         STW,10    INITTFDTFDFWA       STORE WA OF TFD RECORD.          TIC75680
*                                                                       TIC75690
         LI,10     INITBUF3+6          POINT R10 TO WHERE PRIMS GO.
*                                                                       TIC75710
         LI,7      4*INITBUF2+16       POINT R7 TO JUST BEFORE THE
*                                      START OF PRIMIVIVES IN BUFFER.   TIC75730
*        THROUGHOUT THIS SECTION, R13 AND R14 ARE KEEPING TRACK         TIC75740
*        OF HOW LONG THE FORMAL TRANSACTION TEXT GETS -- THAT           TIC75750
*        IS WE ARE CALCULATING THE 'LIGH WATER' POINT OF #.             TIC75760
*                                                                       TIC75770
         LI,13     0                                                    TIC75780
         LI,14     0                                                    TIC75790
*                                                                       TIC75800
*                                                                       TIC75810
*                                                                       TIC75820
INITTFD295 RES     0                                                    TIC75830
         PICKUPCHARACTER78             PRIME R8 WITH A CHARACTER.       TIC75840
INITTFD300 RES     0                                                    TIC75850
         STW,10    INITTFDPRIMFWA      REMEMBER WA OF PRIM'S WORD ZERO.
*        (WE HAVE A BYTE OF TFD IN R8.)                                 TIC75870
         AI,8      0                   SEE IF IT IS OUR FENCE.          TIC75880
         BEZ       INITTFD800          OVER IF IT IS OUR FENCE.         TIC75890
*                                                                       TIC75900
         CI,8      ' '                 TEST FOR BLANK.                  TIC75910
         BE        INITTFD295          SKIP A BLANK.                    TIC75920
*                                                                       TIC75930
*        NOT A BLANK, SO IT SHOULD BE THE                               TIC75940
*        INITIAL CHARACTER OF A PRIMITIVE.  SCAN                        TIC75950
*        THE TALLE OF LEGAL PRIMITIVES LOOKING                          TIC75960
*        FOR A MATCH:                                                   TIC75970
*                                                                       TIC75980
         LI,6      INITTFDPRIMTABLESIZE                                 TIC75990
INITTFD312 LW,9    INITTFDPRIMTABLE-1,6                                 TIC76000
         CB,8      9                   COMPARE THE CHARACTER.           TIC76010
         BE        INITTFD330          OUT ON A MATCH.                  TIC76020
         BDR,6     INITTFD312          OTHERWISE LOOP.                  TIC76030
*                                                                       TIC76040
*        IF WE FELL THROUGH, NOT A LEGAL PRIMITIVE.                     TIC76050
*                                                                       TIC76060
         LI,9      X'400'               LOAD MYPRIM IDENTIFIER BIT.     TIC76070
         OR,9      8                    OR IN THE ACTUAL CHARACTER.     TIC76080
*        (REST OR R9 = 0, WHICH MAKES OK FLAGS FOR LATER)               TIC76090
*                                                                       TIC76100
         LI,14     X'10000'            MYPRIM MAKES THE LENGTH OF THE   TIC76110
*                                      FQM TEXT INDETERMINATE, SO WE    TIC76120
*                                      SET R14 TO THIS BIG NUMBER.      TIC76130
*                                      THE IDEA IS TO SET IS SO HIGH    TIC76140
*                                      THAT IT WON'T BE CHANGED BY      TIC76150
*                                      ANY SUBSEQUENT R13 CALCULATIONS, TIC76160
*                                      AND AT THE SAME TIME WILL RESULT TIC76170
*                                      IN A ZERO LENGTH WHEN WE STORE   TIC76180
*                                      JUST THE RIGHT HALF INTO THE TFD.TIC76190
*                                                                       TIC76200
INITTFD330 RES     0                   HERE ON FOUND PRIM IN TABLE.     TIC76210
         LW,11     9                   COPY TABLE ENTRY IN ORDER TO     TIC76220
*                                      BE ABLE TO CHECK FLAGS LATER.    TIC76230
*                                                                       TIC76240
         SLS,9     16                  ALIGN PRIMITIVE NUMBER.          TIC76250
         STW,9     *INITTFDPRIMFWA     STORE IT INTO TFD.
*                                                                       TIC76270
         CI,8      '@'                 TEST FOR THE                     TIC76280
         BE        INITTFD@             PRIMITIVES THAT                 TIC76290
         CI,8      '#'                   NEED SPECIAL                   TIC76300
         BE        INITTFD#               HANDLING.                     TIC76310
*                                                                       TIC76320
INITTFD337 RES     0
         PICKUPCHARACTER78             GET NEXT CHARACTER.              TIC76330
         CI,8      ''''                IS IT A QUOTE?                   TIC76340
         BE        INITTFD370          IF SO, PROCESS TYPE ONE PRIM.    TIC76350
*                                                                       TIC76360
         CLM,8     INITTFDISITALETTER  TEST FOR LETTER (=FLAG).
         BCS,9     INITTFD343          OVER IF NOT.
*
*        FALL THROUGH ON FLAG.
*
         INT,9     *INITTFDPRIMFWA     SEE IF PREVIOUS FLAG.
         BCS,2     INITTFD340          OVER IF SO.
*
         LW,9      =X'20000000'        SET FLAGS
         STS,9     *INITTFDPRIMFWA      EXIST BIT.
         AI,10     1                   AND CREATE
         LI,9      0                    FLAG WORD IN
         STW,9     *10                   THE PRIMITIVE.
*
INITTFD340 RES     0                   FLAG LETTER IN R8.
         LW,9      =X'80000000'        A FLAG BIT TO SHIFT.
         CI,8      X'20'               SHIFT FOR
         BAZ       %+2                  ANY EBCDIC
         SLS,9     -18                   'COLUMN'
         CI,8      X'10'                  ZONE
         BAZ       %+2                     BITS.
         SLS,9     -9
         AND,8     =X'0F'              AND THEN
         SLS,9     -1                   SHIFT FOR
         BDR,8     %-1                   THE 'ROW'.
*
         STS,9     *10                 OR IN FLAG
         B         INITTFD337           AND CONTINUE.
*
INITTFD343 RES     0
         PICKUPINTEGER789              NOT A QUOTE - GET INTEGER.       TIC76370
         STS,9     *INITTFDPRIMFWA     STORE COUNT INTO PRIM IN TFD.
*                                                                       TIC76390
*        SEE IF THIS IS A PRIMITIVE THAT IS REFLECTED                   TIC76400
*        IN THE LENGTH OF THE FORMAL QUEUE MESSAGE TEXT:                TIC76410
*                                                                       TIC76420
         CI,11     X'30000'            SEE IF CONTRIBUTES FQM TEXT.     TIC76430
         BAZ       INITTFD550          OVER IF NOT.                     TIC76440
*                                                                       TIC76450
         CI,11     X'20000'            SEE IF 'COUNT' CHARS IN TEXT.    TIC76460
         BANZ      INITTFD350          OVER IF SO.                      TIC76470
*                                                                       TIC76480
         LI,9      1                   NOT 'COUNT' CHARS:  MUST BE      TIC76490
*                                      JUST ONE - SPECIAL FOR THE       TIC76500
*                                      'K' PRIMITIVE.                   TIC76510
*                                                                       TIC76520
INITTFD350 RES     0                                                    TIC76530
         AW,13     9                   BUMP CURRENT FQM TEXT POSITION.  TIC76540
*                                                                       TIC76550
         CW,13     14                  SEE IF NEW MAXIMUM.              TIC76560
         BLE       %+2                 OVER IF NOT.                     TIC76570
         STW,13    14                  STORE NEW MAXIMUM.               TIC76580
*                                                                       TIC76590
         B         INITTFD550                                           TIC76600
*                                                                       TIC76610
*                                                                       TIC76620
*                                                                       TIC76630
INITTFD370 RES     0                   HERE ON QUOTED = TYPE ONE PRIM.  TIC76640
*                                                                       TIC76650
         LW,9      =X'10000000'        GET 'TYPE ONE' BIT               TIC76660
         STS,9     *INITTFDPRIMFWA      AND ORS IT INTO PRIMITIVE.
*                                                                       TIC76680
         LW,6      10                  CREATE BYTE                      TIC76690
         AI,6      1                    POINTER INTO                    TIC76700
         SLS,6     2                     THE TFD.                       TIC76710
*                                                                       TIC76720
INITTFD376 RES     0                                                    TIC76730
         PICKUPCHARACTER78             GET A CHARACTER.                 TIC76740
         BEZ       INITTFDBAD          ERROR IF IT'S OUR FENCE.         TIC76750
*                                                                       TIC76760
         CI,8      ''''                IS IT (FINAL) QUOTE?             TIC76770
         BE        INITTFD390          OVER IF SO.                      TIC76780
*                                                                       TIC76790
         CI,8      X'6A'               IS IT A CIRCUMFLEX (UP-ARROW)?   TIC76800
         BNE       INITTFD382          OVER IF NOT.                     TIC76810
*                                                                       TIC76820
         PICKUPCHARACTER78             GET NEXT CHAR.                   TIC76830
         BEZ       INITTFDBAD          ERROR IF AT FENCE.               TIC76840
         EOR,8     =X'F0'               AND                             TIC76850
         CI,8      X'F0'                 WE                             TIC76860
         BAZ      %+4                     CONVERT                       TIC76870
         AI,8     X'9'-X'30'               TWO                          TIC76880
         CI,8     X'10'                     HEX                         TIC76890
         BGE       INITTFDBAD                EBCDIC                     TIC76900
         LW,9      8                          CHARACTERS                TIC76910
         PICKUPCHARACTER78                     TO                       TIC76920
         BEZ       INITTFDBAD                   A                       TIC76930
         EOR,8     =X'F0'                        HEX                    TIC76940
         CI,8      X'F0'                          INTEGER.              TIC76950
         BAZ       %+4                                                  TIC76960
         AI,8      X'9'-X'30'                                           TIC76970
         CI,8      X'10'                                                TIC76980
         BGE       INITTFDBAD                                           TIC76990
         SLS,9     4                                                    TIC77000
         OR,8      9                                                    TIC77010
*                                                                       TIC77020
INITTFD382 RES     0                                                    TIC77030
*                                                                       TIC77040
         STB,8     0,6                 STORE CHARACTER.                 TIC77050
         AI,6      1                   BUMP PRIM POINTER.               TIC77060
         MTW,1     *INITTFDPRIMFWA     BUMP C.C. IN PRIMITIVE.
         B         INITTFD376          AND LOOP.                        TIC77080
*                                                                       TIC77090
INITTFD390 RES     0                                                    TIC77100
         PICKUPCHARACTER78             STEP OVER THE QUOTE.             TIC77110
*                                                                       TIC77120
         AI,6      3-4                 ROUND R6 TO LAST WORD USED.      TIC77130
         SLS,6     -2                                                   TIC77140
         LW,10     6                   AND STORE AS PRIM POINTER.       TIC77150
*                                                                       TIC77160
INITTFD550 AI,10   1                   BUMP TO NEXT PRIM PLACE IN TFD.  TIC77170
*                                                                       TIC77180
         AND,11    =X'FFFF'            ISOLATE PRIM NUMBER.             TIC77190
         CI,11     TFDZ                SEE IF Z = END OF TFD.           TIC77200
         BNE       INITTFD300          IF NOT, BACK FOR MORE.           TIC77210
*                                                                       TIC77220
*        FALL THROUGH ON A Z.                                           TIC77230
*                                                                       TIC77240
         LW,8      *INITTFDPRIMFWA     RETRIEVE FIRST WORD OF Z PRIM.
         CI,8      X'FFFF'             SEE IF Z0.                       TIC77260
         BAZ       INITTFD820          OVER IF SO.                      TIC77270
*                                                                       TIC77280
         LI,14     X'10000'            SET BYTE COUNT TO BE ZERO.       TIC77290
         B         INITTFD820          OVER IF IT WAS A Z.              TIC77300
         PAGE                                                           TIC77310
*                                                                       TIC77320
*                                                                       TIC77330
*                                                                       TIC77340
INITTFD@ RES       0                                                    TIC77350
         PICKUPCHARACTER78             GET NEXT CHARACTER.              TIC77360
         LI,9      X'8000'             LOAD A +0 JUST IN CASE.          TIC77370
         CI,8      '+'                 IS IT A PLUS?                    TIC77380
         BE        INITTFD420          OVER IF SO.                      TIC77390
         CLM,8     ZEROANDNINE         SEE IF DIGIT.                    TIC77400
         BCS,9     INITTFD428          OVER IF NOT.                     TIC77410
         B         INITTFD425          JUST OVER + IF SO.               TIC77420
INITTFD420 RES     0                   HERE IF PLUS:  OR                TIC77430
         STS,9     *10                  IN THE PLUS BIT.                TIC77440
         PICKUPCHARACTER78             AND GET NEXT CHARACTER           TIC77450
*                                                                       TIC77460
INITTFD425 RES     0                                                    TIC77470
         PICKUPINTEGER789              GET THE 'R' VALUE.               TIC77480
         SLS,9     8                   SLIDE 'R' OVER.                  TIC77490
INITTFD428 RES     0                                                    TIC77500
         STS,9     *10                 AND OR IT IN.                    TIC77510
*                                                                       TIC77520
         LI,9      X'80'               LOAD A +0 C FOR TEST BELOW.      TIC77530
*                                                                       TIC77540
         CI,8      ','                 SEE IF COMMA.                    TIC77550
         BNE       INITTFD445          OVER IF NOT.                     TIC77560
*                                                                       TIC77570
         PICKUPCHARACTER78             COMMA:  GET CHAR PAST IT.        TIC77580
         CI,8      '+'                 IS IT A PLUS?                    TIC77590
         BNE       INITTFD435          OVER IF NOT.                     TIC77600
         LI,9      X'80'               WAS PLUS:  OR                    TIC77610
         STS,9     *10                  IN THE PLUS BIT.                TIC77620
         PICKUPCHARACTER78             AND GET ANOTHER CHARACTER.       TIC77630
*                                                                       TIC77640
INITTFD435 RES     0                                                    TIC77650
         PICKUPINTEGER789              GET THE 'C' VLAUE.               TIC77660
INITTFD445 RES     0                                                    TIC77670
         STS,9     *10                 AND OR IT IN.                    TIC77680
         AI,10     1                   BUMP TFD-BUILDIN POINTER.        TIC77690
         B         INITTFD300          AND WE'RE DONE.                  TIC77700
*                                                                       TIC77710
*                                                                       TIC77720
*                                                                       TIC77730
INITTFD# RES       0                                                    TIC77740
         LI,11     0                   CLEAN R11 FOR '+' TEST LATER.    TIC77750
*                                                                       TIC77760
         PICKUPCHARACTER78             GET NEXT CHARACTER.              TIC77770
         CI,8      '+'                 IS IT A PLUS?                    TIC77780
         BNE       INITTFD465          OVER IF NOT.                     TIC77790
         LI,11     X'8000'             WAS PLUS: OR IN                  TIC77800
         STS,11    *10                  THE PLUS BIT (? SET FLAG).      TIC77810
         PICKUPCHARACTER78             GET ANOTHER CHARACTER            TIC77820
*                                                                       TIC77830
INITTFD465 RES     0                                                    TIC77840
         PICKUPINTEGER789              GET THE COUNT                    TIC77850
         STS,9     *10                 OR THE COUNT IN.                 TIC77860
         AI,10     1                   BUMP TFD-BUILDIN POINTER.        TIC77870
*                                                                       TIC77880
         AW,13     9                   BUMP THE 'POSITION' IN THE       TIC77890
*                                      FQM TEXT.  (THIS IS THE CORRECT  TIC77900
*                                      THING TO DO FF THERE WAS         TIC77910
*                                      A PLUS.)                         TIC77920
*                                                                       TIC77930
         CI,11     X'8000'             SEE IF WAS A PLUS.               TIC77940
         BANZ      INITTFD300          DONE IF SO.                      TIC77950
*                                                                       TIC77960
         STW,9     13                  WAS ABSOLUTE:  SET COUNT.        TIC77970
         AI,13     -1                  (BUT START AT ZERO.)             TIC77980
         B         INITTFD300          AND WE'RE DONE.                  TIC77990
         PAGE                                                           TIC78000
*                                                                       TIC78010
*                                                                       TIC78020
*                                                                       TIC78030
INITTFD800 RES     0                   HERE WHEN WE HIT OUR FENCE.      TIC78040
         LI,9      TFDZ                STORE A FAKE Z                   TIC78050
         SLS,9     16                   INTO THE INTERNAL TFD           TIC78060
         STW,9     *10                   IF WE FALL OFF THE END.        TIC78070
         AI,10     1                                                    TIC78080
*                                                                       TIC78090
INITTFD820 RES     0                                                    TIC78100
*                                                                       TIC78110
         LI,3      11                  POINT TO CORRECT HW AND          TIC78120
         STH,14    INITBUF3,3           STORE MAX FQM TEXT LENGTH.      TIC78130
*                                                                       TIC78140
*        R10 HAS LWA+1 OF BUILT TFD.
*
         LW,9      INITTFDTFDFWA       GET FWA.
         LW,8      10                  LWA+1 MINUS FWA
         SW,8      9                    IS NUMBER OF WORDS.
         STH,8     *9                  STORE TFD LENGTH.
*
         LW,8      10                  COMPUTE THE
         AI,8      -INITBUF3            RECORD LENGTH.
*
*        TEST HERE TO SEE IF THE TFD THAT WE
*        JUST BUILT IS TOO LONG FOR THE EQU'ED
*        BUFFER LENGTH.  NOTE THAT THERE IS
*        SOME CHANCE THAT, IF THE TFD IS VERY LONG,
*        WE RAN OFF THE END OF INITBUF3 BEFORE WE
*        GOT HRE TO MAKE THIS TEST.
*
         CI,8      BYTESPERRANDOMBLOCK/4 SEE IF LONGER THAN THE
         BG        INITTFDLONG         EQUED BUFFER.  OUT IF SO.
*
         LW,11     INITTFDNEXTBUF4WA   SEE IF RECORD WILL
         AW,8      11                   FIT IN OUTPUT
         CI,8      INITBUF4+(BYTESPERRANDOMBLOCK/4) BUFFER.
         BLE       INITTFD870          OVER IF WILL FIT.
*
*        FALL THROUGH IF NEW TFD RECORD WILL NOT FIT INTO
*        REMAINDER OF THE INITBUF4 OUTPUT BUFFER.
*
*        SO WE MUST WRITE OUT CURRENT BUFFER CONTENT.
INITTFD830 RES     0
*                                      (R11 HAS LWA+1 OF BUFFER DATA)
         LI,8      0                   STORE A ZERO AT END
         STW,8     *11                  OF RECORDS IN BUFFER.
*
*        NOW THE BLOCK IS READY TO WRITE.
*                                                                       TIC78160
         MTW,1     INITGRANULE         BUMP TO NEXT GRANULE.
*                                                                       TIC78180
*        CHAIN THIS BLOCK ON TO THE IN-CORE BLOCK CHAIN.                TIC78190
*                                                                       TIC78200
         MTW,0     INITCOUNTING        SEE IF JUST COUNTING GRANULES.
         BGZ       INITTFD856          AVOID ACTUAL WRITE ETC IF SO.
*
         LI,5      4                   GET EIGHT WORDS
         BAL,#BAL  #FIND#DWS            FOR CHAIN ENTRY.
         BEZ       INITNOPAGES         ERROR IF AREN'T ANY.
         SLS,4     1                   WA OF ACQUIRED SPACE.
*                                                                       TIC78250
         LW,9      INITGRANULE         INTERNAL GRANULE NUMBER.
         STW,9     1,4                  INTO CHAIN ENTRY.
*
         LI,6      4*INITBUF5          'KEY'
         LW,7      4                    INTO
         SLS,7     2                     THE
         AW,7      =X'12000008'           CHAIN     (KEY 2 WORDS IN)
         MBS,6     0                       ENTRY.
*                                                                       TIC78380
         LI,9      #TFDI#GRANULE#KEY#CHAIN                              TIC78390
         B         %+2                 SCAN DOWN                        TIC78400
         LW,9      *9                    TO FIND                        TIC78410
         MTW,0     *9                    END OF                         TIC78420
         BNEZ      %-2                    THE CHAIN.                    TIC78430
*                                                                       TIC78440
         STW,4     *9
         LI,8      0                   AND SET LAST (NEW) GUY'S         TIC78460
         STW,8     *4
*                                                                       TIC78480
INITTFD845 RES     0
         M:WRITE   F:TICI,(BUF,INITBUF4),(SIZE,2048),;
                   (BTD,0),(BLOCK,*INITGRANULE)
         M:CHECK   F:TICI,(ERR,INITTICIERR),(ABN,INITTICIABN)
*
INITTFD856 RES     0
         MTW,0     INITBUF2            SEE IF DUMP-BUFFER-ON-EOF.
         BEZ       INITTFD900          PROBABLY DONE IF SO.
*
*
         LI,11     INITBUF4            INDICATE INITBUF4
         STW,11    INITTFDNEXTBUF4WA    IS NOW EMPTY.
*
INITTFD870 RES     0                   HERE TO COPY THE BUILT
*                                       TFD RECORD FROM INITBUF3
*                                        TO THE BUFFER IN INITBUF4.
*
*        R10 HAS THE LWA+1 OF THE RECORD IN INITBUF3.
*
*        R11 HAS THE WA OF THE FIRST FREE WORD IN INITBUF4.
*
*        AND WE PREVIOUSLY CHECKED SO WE KNOW THE RECORD WILL FIT.
*
         LI,12     INITBUF3
*
         LW,8      *12                 COPY
         STW,8     *11                  FROM
         AI,12     1                     INITBUF3
         AI,11     1                      TO
         CW,12     10                      INITBUF4.
         BL        %-5
*
         LI,8      4*(INITBUF3+1)           REMEMBER THIS KEY IN
         LW,9      =(4*INITBUF5+20*256*256*256) CASE IT TURNS OUT TO BE
         MBS,8     0                          LAST RECORD IN BLOCK.
*
         STW,11    INITTFDNEXTBUF4WA   REMEMBER WHERE WE ARE IN INITBUF4
*                                                                       TIC78640
         B         INITTFD200          AND DO NEXT TFD ...              TIC78650
         PAGE                                                           TIC78660
*                                                                       TIC78670
*                                                                       TIC78680
*                                                                       TIC78690
INITTFDPRIMTABLE RES 0                                                  TIC78700
         GEN,8,7,1,16 'Z',0,0,TFDZ                                      TIC78710
         GEN,8,7,1,16 'X',0,0,TFDX                                      TIC78720
         GEN,8,7,1,16 'A',1,0,TFDA                                      TIC78730
         GEN,8,7,1,16 'B',1,0,TFDB                                      TIC78740
         GEN,8,7,1,16 'C',1,0,TFDC                                      TIC78750
         GEN,8,7,1,16 'D',1,0,TFDD                                      TIC78760
         GEN,8,7,1,16 'E',1,0,TFDE                                      TIC78770
         GEN,8,7,1,16 'F',1,0,TFDF                                      TIC78780
         GEN,8,7,1,16 'I',1,0,TFDI                                      TIC78790
         GEN,8,7,1,16 'J',1,0,TFDJ                                      TIC78800
         GEN,8,7,1,16 'K',0,1,TFDK     (NOTE SPECIAL TREATMENT)         TIC78810
         GEN,8,7,1,16 'L',1,0,TFDL                                      TIC78820
         GEN,8,7,1,16 'M',1,0,TFDM                                      TIC78830
         GEN,8,7,1,16 'P',0,0,TFDP                                      TIC78840
         GEN,8,7,1,16 'G',1,0,TFDG                                      TIC78850
         GEN,8,7,1,16 '@',0,0,TFD@                                      TIC78860
         GEN,8,7,1,16 '#',0,0,TFD#                                      TIC78870
         GEN,8,7,1,16 'Y',0,0,TFDY                                      TIC78880
INITTFDPRIMTABLESIZE EQU %-INITTFDPRIMTABLE                             TIC78890
*
         BOUND     8
INITTFDISITALETTER GEN,32,32 X'81','Z'
         PAGE                                                           TIC78900
*                                                                       TIC78910
*                                                                       TIC78920
*                                                                       TIC78930
INITTFDBAD RES     0                                                    TIC78940
*E*  MESSAGE:     'BAD TFD IGNORED'
*E*  DESCRIPTION: ONE OF THE FOLLOWING ERRORS FOUND IN TFD:  TFD
*E*               RECORD TOO SHORT; ^ WAS LAST CHAR. OF RECORD.
         #OUT      'BAD TFD IGNORED'
         B         INITTFD200                                           TIC78960
*
*
*
INITTFDLONG RES    0
*E*  MESSAGE:     'TOO LONG TFD IGNORED'
*E*  DESCRIPTION: TFD TOO LONG TO FIT IN BUFFER SIZE ALLOWED FOR
*E*               INTERNAL TFD RECORD.
         #OUT      'TOO LONG TFD IGNORED'
         B         INITTFD200
         PAGE                                                           TIC78970
*                                                                       TIC78980
*                                                                       TIC78990
*                                                                       TIC79000
INITTFDERR RES     0                                                    TIC79010
INITTFDABN RES     0                                                    TIC79020
         LB,9      10                  GET CLEAN ERR/ABN CODE.
         CI,9      6                   SEE IF IT E-O-F.
         BNE       %+4                 OVER IF NOT E-O-F.
*
         LI,9      0                   STORE OUR
         STW,9     INITBUF2             EOF SIGNAL AND
         B         INITTFD830            WRITE LAST BUFFER.
*
*E*  MESSAGE:     'BAD TFDX FILE'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN HAS OCCURRED (OTHER THAN
*E*               EOF) ON F:TFDX.
         #OUT      'BAD TFDX FILE'
         M:XXX
         PAGE                                                           TIC79080
*                                                                       TIC79090
*                                                                       TIC79100
*                                                                       TIC79110
INITTFD900 RES      0                  HERE AFTER DOING TFDX-TFDI COPY. TIC79120
         M:SETDCB  F:TFDX,(ERR,INITTFD902),(ABN,INITTFD902)             TIC79130
         M:CLOSE   F:TFDX                                               TIC79140
INITTFD902 RES     0                                                    TIC79150
         MTW,0     INITCOUNTING        SEE IF JUST COUNTING.
         BEZ       INITTFD999          OVER IF NOT.
*
*
*
*        HERE WE CREATE OUR INTERNAL FILE,
*        NOW THAT WE (MORE-OR-LESS) KNOW HOW
*        BIG IT SHOULDD BE.
*
*        THE NUMBER OF GRANULES THAT THE TFDS REQUIRED
*        IS NOW IN CELL 'INITGRANULE'.
*
         LW,8      INITGRANULE         TFD GRANULES.
         AI,8      20+20+7             PLUS STAX PLUS DELX PLUS CMDS.
*
*        OWING TO AN ERROR IN UTS (AS OF 9 MAY 173), THE
*        (RANDOM) SPECIFICATION IS INEFFECTIVE WHEN USED IN
*        CONJUNCTION WITH (RSTORE).  SO WE INDICATED (RANDOM)
*        IN THE DCB AN HERE MENTION ONLY (RSTORE).
*
         M:OPEN    F:TICI,(RSTORE,*8),(ERR,OPENTICIERR),;
                                      (ABN,OPENTICIABN)
*
         LI,8      0-1                 START AT THE BEGINNING
         STW,8     INITGRANULE          OF THE INTERNAL FILE.
         MTW,-1    INITCOUNTING        INDICATE NOT COUNTING.
         B         INITTFD110          AND GO DO THE COPYING.
*
OPENTICIERR RES    0
OPENTICIABN RES    0
*E*  MESSAGE:     'ERROR OPENING THE INTERNAL FILE'
*E*  DESCRIPTION: ERROR ON M:OPEN OF F:TICI
         #OUT      'ERROR OPENING THE INTERNAL FILE'
         M:XXX
*
         BOUND     8
INITTFD999 RES     0
         PAGE                                                           TIC79160
*                                                                       TIC79170
*        WE COPY THE F:STAX FILE TO A KEYED FILE - F:STAK.              TIC79180
*        WE WILL USE F:STAK TO OBTAIN NEEDED +-TYPE RECORDS.            TIC79190
*                                                                       TIC79200
INITSTA020 RES     0                                                    TIC79210
         M:READ    F:STAX,(BUF,INITBUF2),(BTD,1),(SIZE,2047),;          TIC79220
                   (ERR,INITSTACOPYINERR),(ABN,INITSTACOPYINABN)        TIC79230
         LW,7      F:STAX+4            GET ARS.                         TIC79240
         SLS,7     -17                  ALIGN ARS.                      TIC79250
*                                                                       TIC79260
         LI,8      8                   MAKE KEY INTO TEXTC.             TIC79270
         STB,8     INITBUF2            (THAT'S WHY WE READ WITH A BTD)  TIC79280
*                                                                       TIC79290
         M:WRITE   F:STAK,(BUF,INITBUF2),(BTD,1),(SIZE,*7),;            TIC79300
                   (KEY,INITBUF2),(NEWKEY),;
                   (ERR,INITSTACOPYOUTERR),(ABN,INITSTACOPYOUTABN)      TIC79320
         B         INITSTA020                                           TIC79330
*                                                                       TIC79340
INITSTA035 RES     0                   HERE WHEN F:STAX COPIED.         TIC79350
         M:SETDCB F:STAX,(ERR,INITSTA050)
         M:READ   F:STAX,(ERR,INITSTA050),(BUF,DUMMYBUF),;
                  (SIZE,1),(KEY,=X'01C20000')
INITSTA050        ;
         M:SETDCB F:STAX,(ERR,0)
*                                                                       TIC79370
*                                                                       TIC79380
*                                                                       TIC79390
*                                                                       TIC79400
*        HERE WE INITIALIZE THE STAI FILE.                              TIC79410
*                                                                       TIC79420
*                                                                       TIC79500
*                                                                       TIC79510
INITSTA110 RES     0
         LI,11     INITBUF3            POINT R11 TO OUTPUT BUFFER.      TIC79520
INITSTA200 RES     0                                                    TIC79530
*                                                                       TIC79540
*        GET A RECORD:                                                  TIC79550
*                                                                       TIC79560
         M:READ    F:STAX,(BUF,INITBUF2),(BTD,0),(SIZE,2047)            TIC79570
         M:CHECK   F:STAX,(ERR,INITSTAERR),(ABN,INITSTAABN)             TIC79580
*                                                                       TIC79590
         MTW,1     INITSTANTH          BUMP OUR RECORD COUNT.           TIC79600
*                                                                       TIC79610
         LW,10     F:STAX+4            GET 'ACTUAL RECORD SIZE'.        TIC79620
         SLS,10    -17                 AND ALIGN IT.                    TIC79630
*                                                                       TIC79640
         CI,10     9                   SEE IF RECORD UNREASONABLY SHORT.TIC79650
         BLE        INITSTABAD          OUT IF ERRONEOUS.               TIC79660
*                                                                       TIC79670
*        WE HAVE A RECORD.                                              TIC79680
*                                                                       TIC79690
*        ROUND RECORD LENGTH UP TO A MULTIPLE OF FOUR.                  TIC79700
*        BUT INSURE WE ADD AT LEAST ONE BLANK TO END.                   TIC79710
*                                                                       TIC79720
         LI,8      ' '                 A BLANK TO STORE.                TIC79730
         LW,#ARG   10                  COPY BYTE LENGTH TO INDEX.       TIC79740
         STB,8     INITBUF2,#ARG       STORE A BLANK.                   TIC79750
         AI,10     1                   AND BUMP.                        TIC79760
         CI,10     3                   AT WORD BOUNDARY?                TIC79770
         BANZ      %-4                 CONTINUE UNTIL WE ARE.           TIC79780
*
         LI,6      8                   BLANKS AT END IN
         AI,#ARG   1                    CASE PLUSES DO NOT
         STB,8     INITBUF2,#ARG         COME OUT EVEN.
         BDR,6     %-2
*                                                                       TIC79790
*        SCAN FOR +-TYPE NPS REPLACEMENT.                               TIC79800
*                                                                       TIC79810
INITSTA300 LI,6    4*INITBUF2+8        WHERE TO START SCANNING.
         LW,7      10                  SIZE PLUS                        TIC79830
         AI,7      4*INITBUF2           START IS END+1.
*                                                                       TIC79850
INITSTA305 LB,8    0,6                                                  TIC79860
         CI,8      ' '                                                  TIC79870
         BNE       INITSTA390                                           TIC79880
         AI,6      1                                                    TIC79890
         LB,8      0,6
         CI,8      '+'
         BNE       INITSTA391                                           TIC79910
*                                                                       TIC79920
*        FALL THROUGH ON HAVE A +-TYPE TO REPLACE.                      TIC79930
*                                                                       TIC79940
*        FIRST MUST MAKE A TEXTE KEY ON A WORD BOUNDARY.                TIC79950
*                                                                       TIC79960
         LW,14     ='    '             BLANK
         STW,14    INITBUF5+508         OUT
         STW,14    INITBUF5+509          KEY
         STW,14    INITBUF5+510           AREA.
         LW,14     6                   REMEMBER WHERE + IS.             TIC80010
         LI,5      4*(INITBUF5+508)+1  WHERE TO PUT KEY.
INITSTA320 LB,8    0,6                                                  TIC80030
         CI,8      ' '                                                  TIC80040
         BE        INITSTA355                                           TIC80050
         STB,8     0,5                                                  TIC80060
         AI,6      1                                                    TIC80070
         AI,5      1                                                    TIC80080
         CI,5     4*(INITBUF5+508)+9
         BLE       INITSTA320                                           TIC80100
*                                                                       TIC80110
*        FALL THROUGH ON A BAD +-TYPE NPS.                              TIC80120
*                                                                       TIC80130
INITSTA340 RES     0                                                    TIC80140
         #SNAP,15 'BAD +-TYPE NPS -- RECORD IGNORED'
         B         INITSTA110                                           TIC80160
*                                                                       TIC80170
INITSTA355 RES     0                                                    TIC80180
         LI,8      8                   LENGTH TO MAKE                   TIC80190
         STB,8     INITBUF5+508         A TEXTC KEY.
*                                                                       TIC80210
         M:READ    F:STAK,(BUF,INITBUF5),;
                   (SIZE,2032),(KEY,INITBUF5+508),;
                   (BTD,0),;
                   (ERR,INITSTASTAKERR),(ABN,INITSTASTAKABN)            TIC80230
*                                                                       TIC80240
         LW,13     F:STAK+4            GET ARS.                         TIC80250
         SLS,13    -17                 ALIGN ARS.                       TIC80260
*                                                                       TIC80270
*        WHEN HERE, R14 HAS BA OF THE NPS WE ARE REPLACING (THE BA OF   TIC80280
*        THE PLUS) AND R6 HAS THE BA OF THE CHARACTER FOLLOWING THE NPS.TIC80290
*                                                                       TIC80300
*        ALSO, R7 HAS THE BA OF THE LAST-BYTE-PLUS-ONE IN THE RECORD.   TIC80310
*                                                                       TIC80320
*        R11 HAS THE NUMBER OF BYTES IN THE +-TYPE RECORD.  THE RECORD  TIC80330
*        BEGINS WITH ITS KEY AND IS IN INITBUF6.                        TIC80340
*                                                                       TIC80350
*        THE RECORD WE ARE INSERTING INTO IS IN INITBUF2.  R6 AND R7    TIC80360
*        AND R14 ALL POINT WITHIN INITBUF2.                             TIC80370
*                                                                       TIC80380
*                                                                       TIC80390
         LW,9      13                  (SIZE OF PLUS WITH KEY)
         AI,9      -8                  (SIZE OF PLUS TEXT)
         AW,9      14                  ...
         SW,9      6                   (SIZE OF PLUS) - (SIZE OF NPS)
*
         AW,10     9                   UPDATE R10 TO NEW RECORD ARS.
*                                                                       TIC80450
*        HAVE IN R9 THE SIZE HOLE WE NEED TO MAKE IN THE INITBUF2       TIC80460
*        RECORD SO THAT NPS-RECORD WILL FIT.                            TIC80470
*                                                                       TIC80480
         LW,#ARG   7                   MAKE SURE THAT                   TIC80490
         AW,#ARG   9                    RESULTANT RECORD                TIC80500
         CI,#ARG   4*INITBUF2+BYTESPERRANDOMBLOCK-8 WILL FIT IN FINAL GR
         BLE       INITSTA370          OVER IF SMALL ENOUGH.            TIC80520
*                                                                       TIC80530
*        FALL THROUGH ON RECORD TOO BIG UPON EXPANDING.                 TIC80540
*                                                                       TIC80550
*E*  MESSAGE:     'EXPANDED STAX RECORD TOO BIG -- IGNORED'
*E*  DESCRIPTION: RECORD FOR INTERNAL VERSION OF F:STAX (F:STAK) IS
*E*               TOO BIG TO FIT INTO INITBUF2.
         #OUT      'EXPANDED STAX RECORD TOO BIG -- IGNORED'            TIC80560
         B         INITSTA110                                           TIC80570
*                                                                       TIC80580
INITSTA370 RES                                                          TIC80590
*                                                                       TIC80600
*        WE MUST MOVE BYTES (FROM HIGH ENDS OF STRINGS) STARTING        TIC80610
*        WITH *R7  --> *#ARG AND MOVING 'TIL WE GET BACK TO *R6.        TIC80620
*                                                                       TIC80630
         LB,8      0,7                 DO A                             TIC80640
         STB,8     0,#ARG               POSSIBLY                        TIC80650
         AI,7      -1                    OVERLAPPING
         AI,#ARG   -1                     BYTE
         CW,7      6                       STRING                       TIC80680
         BGE       %-5                      MOVE.                       TIC80690
*                                                                       TIC80700
*        NOW WE HAVE MADE A SPACE FOR THE NPS-RECORD.                   TIC80710
*        MOVE IT, LESS ITS KEY.                                         TIC80720
*                                                                       TIC80730
*        R14 HAS BA OF THE SPACE.                                       TIC80740
*                                                                       TIC80750
*        R13 HAS TOTAL CHAR COUNT (ARS) OF THE NPS-RECORD.              TIC80760
*                                                                       TIC80770
         LI,6      4*INITBUF5+8        WHERE TO MOVE FROM.
         LW,7      14                  WHERE TO MOVE TO.                TIC80790
         LW,8      13                  HOW MANY CHARACTERS TO MOVE.     TIC80800
         AI,8      -8                                                   TIC80810
*                                                                       TIC80820
         MBS678                        DO THE MOVE.                     TIC80830
*                                                                       TIC80840
         B         INITSTA300          AND GO 'WAY BACK AND LOOK        TIC80850
*                                       FOR ANOTHER PLUS.               TIC80860
*                                                                       TIC80870
*                                                                       TIC80880
*        END OF THE LOOP THAT BEGINS AFTER INITSTA300 IS HERE.          TIC80890
*                                                                       TIC80900
INITSTA390 AI,6    1                                                    TIC80910
INITSTA391 CW,6    7                                                    TIC80920
         BL        INITSTA305                                           TIC80930
*                                                                       TIC80940
*        FALL THROUGH WHEN THERE ARE NO MORE +-TYPE NPS TO REPLACE.     TIC80950
*                                                                       TIC80960
*        R10 STILL HAS THE RECORD'S ARS.                                TIC80970
*                                                                       TIC80980
         AI,10     3                   ROUND RECORD SIZE                TIC80990
         SLS,10    -2                   INTO WORDS.                     TIC81000
         AI,10     1                     INCLUDING CONTROL WORD.        TIC81010
*                                                                       TIC81020
*        SEE IF ENOUGH SPACE IN OUTPUT BUFFER:                          TIC81030
*                                                                       TIC81040
         LW,8      10                  WORDS IN RECORD.                 TIC81050
         AW,8      11                  PLUS WHERE WE ARE IN BUFFER.     TIC81060
         CI,8      INITBUF3+(BYTESPERRANDOMBLOCK/4)-1 SEE IF ENUF ROOM.
         BLE       INITSTA600          OVER IF ROOM.                    TIC81080
*                                                                       TIC81090
*        READY TO WRITE THE STATION REOORD.                             TIC81100
*                                                                       TIC81110
INITSTA410 RES     0                                                    TIC81120
         MTW,1     INITGRANULE         BUMP TO NEXT INTERNAL GRANULE.
*                                                                       TIC81140
*        CHAIN THIS BLOCK ON THE THE IN-CORE BLOCK KEY CHAIN.           TIC81150
*                                                                       TIC81160
         LI,5      2                   GET FOUR WORDS
         BAL,#BAL  #FIND#DWS            TO HOLD KEY AND BLOCK
         BEZ       INITNOPAGES           NUMBER IN CHAIN.
         SLS,4     1                   (DA TO WA)
*
         LW,8      INITGRANULE         COPY GRANULE
         STW,8     1,4                  NUMBER INTO ENTRY.
*
         LD,8      INITBUF4            COPY
         STW,8     2,4                  THE
         STW,9     3,4                   KEY.
*                                                                       TIC81290
         LI,9      #STAI#GRANULE#KEY#CHAIN                              TIC81300
         B         %+2                 SCAN DOWN                        TIC81310
         LW,9      *9                   TO FIND                         TIC81320
         MTW,0     *9                    END OF                         TIC81330
         BNEZ      %-2                    THE CHAIN.                    TIC81340
*                                                                       TIC81350
         STW,4     *9                  PUT NEW GUY ON THE END.
         LI,8      0                   AND SET LAST (NEW) GUY'S         TIC81370
         STW,8     *4                   POINTER TO ZERO.
*                                                                       TIC81390
*        WHEN HERE, R11 POINTS TO THE FIRST                             TIC81400
*        UNUSED WORD IN THE BUFFER.                                     TIC81410
*                                                                       TIC81420
         LI,8      0                   PUT A FENCE                      TIC81430
         STW,8     *11                  IN THE BUFFER.                  TIC81440
*                                                                       TIC81450
         M:WRITE   F:TICI,(BUF,INITBUF3),(SIZE,2048),;
                   (BTD,0),(BLOCK,*INITGRANULE)
         M:CHECK   F:TICI,(ERR,INITTICIERR),(ABN,INITTICIABN)
*                                                                       TIC81490
         MTW,0     INITBUF2            SEE IF THERE WAS AN E-O-F.       TIC81500
         BEZ       INITSTA900          DONE IF SO.                      TIC81510
*                                                                       TIC81520
         LI,11     INITBUF3            RESET OUTPUT BUFFER POINTER.     TIC81530
*                                                                       TIC81540
INITSTA600 RES     0                                                    TIC81550
         LD,8      INITBUF2            REMEMBER                         TIC81560
         STD,8     INITBUF4             LATEST KEY.                     TIC81570
*                                                                       TIC81580
*        R10 STILL HAS SIZE OF OUTPUT RECORD IN WORDS.                  TIC81590
*                                                                       TIC81600
         STH,10    *11                 STORE COUNT CONTROL WORD.        TIC81610
         AI,11     1                   AND BUMP BUFFER POINTER.         TIC81620
         AI,10     -1                  COUNT OF WORDS TO MOVE.          TIC81630
*                                                                       TIC81640
         LI,12     INITBUF2            POINT TO INPUT BUFFER.           TIC81650
         LW,8      *12                 MOVE                             TIC81660
         STW,8     *11                  RECORD                          TIC81670
         AI,12     1                     TO                             TIC81680
         AI,11     1                      OUTPUT                        TIC81690
         BDR,10    %-4                     BUFFER.                      TIC81700
*                                                                       TIC81710
         B         INITSTA200                                           TIC81720
         PAGE                                                           TIC81730
*                                                                       TIC81740
*                                                                       TIC81750
*                                                                       TIC81760
INITSTAERR RES     0                                                    TIC81770
INITSTAABN RES     0                                                    TIC81780
         LB,8      10                  GET CLEAN ERR/ABN CODE.          TIC81790
         CI,8      6                   SEE IF IT IS E-O-F.              TIC81800
         BNE       %+4                 OVER IF NOT E-O-F.               TIC81810
*                                                                       TIC81820
         LI,8      0                   STORE A                          TIC81830
         STW,8     INITBUF2             EOF SIGNAL                      TIC81840
         B         INITSTA410            AND WRITE LAST BUFFER.         TIC81850
*                                                                       TIC81860
INITSTABADMESS RES 0
*E*  MESSAGE:     'BAD STAX/STAI/STAK FILE'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN HAS OCCURRED (OTHER
*E*               THAN EOF) DURING COPY OF F:STAX FILE.
         #OUT      'BAD STAX/STAI/STAK FILE'
         M:XXX
*                                                                       TIC81890
*                                                                       TIC81900
*                                                                       TIC81910
INITSTACOPYINERR RES 0                                                  TIC81920
INITSTACOPYINABN RES 0                                                  TIC81930
         LB,8      10                  ISOLATE ERR/ABN CODE.            TIC81940
         CI,8      6                   SEE IF E-O-F.                    TIC81950
         BE        INITSTA035          BRANCH IF END-OF-FILE.           TIC81960
         B         INITSTABADMESS
*                                                                       TIC81990
*                                                                       TIC82000
*                                                                       TIC82010
INITSTACOPYOUTERR RES 0                                                 TIC82020
INITSTACOPYOUTABN RES 0                                                 TIC82030
         B         INITSTABADMESS
*                                                                       TIC82060
*                                                                       TIC82070
*                                                                       TIC82080
INITSTASTAKERR RES 0                                                    TIC82090
INITSTASTAKABN RES 0                                                    TIC82100
         B         INITSTABADMESS
         PAGE                                                           TIC82130
*                                                                       TIC82140
*                                                                       TIC82150
*                                                                       TIC82160
INITSTABAD RES     0                                                    TIC82170
         B         INITSTABADMESS
         PAGE                                                           TIC82200
*                                                                       TIC82210
*                                                                       TIC82220
*                                                                       TIC82230
INITSTA900 RES      0                                                   TIC82240
         M:SETDCB  F:STAX,(ERR,INITSTA902),(ABN,INITSTA902)             TIC82250
         M:CLOSE   F:STAX                                               TIC82260
INITSTA902 RES     0                                                    TIC82270
         M:SETDCB  F:STAK,(ERR,INITSTA904),(ABN,INITSTA904)             TIC82280
         M:CLOSE   F:STAK                                               TIC82290
INITSTA904 RES     0                                                    TIC82300
         PAGE                                                           TIC82310
*                                                                       TIC82320
*        COPY THE F:DELX FILE TO OUR INTERNAL FILE.
*                                                                       TIC82340
*        LIKE THE STAX COPY, BUT WITHOUT +-TYPE COMPLICATIONS.          TIC82350
*                                                                       TIC82360
*                                                                       TIC82440
         LI,11     INITBUF3            POINT R11 TO OUTPUT BUFFER.      TIC82450
*                                                                       TIC82460
INITDEL200 RES     0                                                    TIC82470
         M:READ    F:DELX,(BUF,INITBUF2),(BTD,0),(SIZE,2047)            TIC82480
         M:CHECK   F:DELX,(ERR,INITDELERR),(ABN,INITDELABN)             TIC82490
*                                                                       TIC82500
         MTW,1     INITDELNTH          BUMP OUR RECORD COUNT.           TIC82510
*                                                                       TIC82520
         LW,10     F:DELX+4            GET 'ACTUAL RECORD SIZE'.        TIC82530
         SLS,10    -17                 AND ALIGN IT.                    TIC82540
*                                                                       TIC82550
         CI,10     9                   SEE IF RECORD UNREASONABLY SHORT.TIC82560
         BLE       INITDELBAD          OUT IF ERRONEOUS.                TIC82570
*                                                                       TIC82580
*        WE HAVE A RECORD.                                              TIC82590
*                                                                       TIC82600
*        ROUND RECORD LENGTH UP TO A MULTIPLE OF FOUR.                  TIC82610
*        BUT INSURE WE ADD AT LEAST ONE BLANK TO END.                   TIC82620
*                                                                       TIC82630
         LI,8      ' '                 A BLANK TO STORE.                TIC82640
         LW,#ARG   10                  COPY BYTE LENGTH TO INDEX.       TIC82650
         STB,8     INITBUF2,#ARG       STORE A BLANK.                   TIC82660
         AI,10     1                   AND BUMP.                        TIC82670
         CI,10     3                   SEE IF AT WORD BOUNDARY.         TIC82680
         BANZ      %-4                 CONTINUE UNTIL WE ARE.           TIC82690
*                                                                       TIC82700
         SLS,10    -2                  RECORD SIZE IN WORDS.            TIC82710
         AI,10     1                   PLUS ONE CONTROL WORD.           TIC82720
*                                                                       TIC82730
*        SEE IF ENOUGH SPACE IN OUTPUT BUFFER:                          TIC82740
*                                                                       TIC82750
         LW,8      10                  WORDS IN NEW RECORD.             TIC82760
         AW,8      11                  PLUS WHERE WE ARE IN BUFFER.     TIC82770
         CI,8      INITBUF3+(BYTESPERRANDOMBLOCK/4)-1 SEE IF ENUF ROOM.
         BLE       INITDEL600          OVER IF ROOM.                    TIC82790
*                                                                       TIC82800
*        TIME TO WRITE A BUFFER-FULL TO DELI.                           TIC82810
INITDEL410 RES     0                                                    TIC82820
         MTW,1     INITGRANULE         BUMP TO NEXT INERNAL GRANULE.
*                                                                       TIC82840
*        CHAIN THIS BLOCK ON THE IN-CORE BLOCK KEY CHAIN.               TIC82850
*                                                                       TIC82860
         LI,5      2                   GET FOUR WORDS
         BAL,#BAL  #FIND#DWS            FOR THE CHAIN ENTRY.
         BEZ       INITNOPAGES
         SLS,4     1
*
         LW,8      INITGRANULE         THIS GRANULE'S NUMBER.
         STW,8     1,4                 STORED INTO ENTRY.
*
         LD,8      INITBUF4            COPY KEY
         STW,8     2,4                  INTO THE
         STW,9     3,4                   CHAIN ENTRY.
*                                                                       TIC82990
         LI,9      #DELI#GRANULE#KEY#CHAIN                              TIC83000
         B         %+2                 SCAN DOWN                        TIC83010
         LW,9      *9                   TO FIND                         TIC83020
         MTW,0     *9                    END OF                         TIC83030
         BNEZ      %-2                    THE CHAIN.                    TIC83040
*                                                                       TIC83050
         STW,4     *9                  PUT NEW GUY ON THE END.
         LI,8      0                   AND SET LAST (NEW) GUY'S         TIC83070
         STW,8     *4                   POINTER (FLINK) TO ZERO.
*                                                                       TIC83090
*        WHEN HERE, R11 POINTS TO THE                                   TIC83100
*        FIRST UNUSED WORD IN THE BUFFER.                               TIC83110
*                                                                       TIC83120
         LI,8      0                   PUT A FENCE                      TIC83130
         STW,8     *11                  IN THE BUFFER.                  TIC83140
*                                                                       TIC83150
         M:WRITE   F:TICI,(BUF,INITBUF3),(SIZE,2048),;
                   (BTD,0),(BLOCK,*INITGRANULE)
         M:CHECK   F:TICI,(ERR,INITTICIERR),(ABN,INITTICIABN)
*                                                                       TIC83190
         MTW,0     INITBUF2            SEE IF WE HAD A F:DELX E-O-F.    TIC83200
         BEZ       INITDEL900          DONE IF SO.                      TIC83210
*                                                                       TIC83220
         LI,11     INITBUF3            RESET OUTPUT BUFFER POINTER.     TIC83230
*                                                                       TIC83240
INITDEL600 RES     0                                                    TIC83250
         LD,8      INITBUF2            REMEMBER                         TIC83260
         STD,8     INITBUF4             LATEST KEY.                     TIC83270
*                                                                       TIC83280
*        R10 STILL HAS SIZE OF TO-OUTPUT RECORD IN WORDS.               TIC83290
*                                                                       TIC83300
         STH,10    *11                 STORE COUNT CONTROL WORD.        TIC83310
         AI,11     1                   AND BUMP BUFFER POINTER.         TIC83320
         AI,10     -1                  COUNT OF WORDS TO MOVE.          TIC83330
*                                                                       TIC83340
         LI,12     INITBUF2            LOAD WHERE TO MOVE FROM.         TIC83350
         LW,8      *12                 MOVE                             TIC83360
         STW,8     *11                  RECORD                          TIC83370
         AI,12     1                     TO                             TIC83380
         AI,11     1                      OUTPUT                        TIC83390
         BDR,10    %-4                     BUFFER.                      TIC83400
         B         INITDEL200                                           TIC83410
         PAGE                                                           TIC83420
*                                                                       TIC83430
*                                                                       TIC83440
*                                                                       TIC83450
INITDELERR RES     0                                                    TIC83460
INITDELABN RES     0                                                    TIC83470
         LB,8      10                  GET CLEAN ERR/ABN CODE.          TIC83480
         CI,8      6                   SEE IF IT IS E-O-F.              TIC83490
         BNE       %+4                 OVER IF NOT E-O-F.               TIC83500
*                                                                       TIC83510
         LI,8      0                   STORE OUR                        TIC83520
         STW,8     INITBUF2             EOF SIGNAL                      TIC83530
         B         INITDEL410            AND WRITE LAST BUFFER.         TIC83540
*                                                                       TIC83550
INITDELBADMESS RES 0
*E*  MESSAGE:     'BAD DELX/DELI FILE'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN HAS OCCURRED (OTHER THAN
*E*               EOF) DURING COPY OF F:DELX
         #OUT      'BAD DELX/DELI FILE'
         M:XXX
         PAGE                                                           TIC83580
*                                                                       TIC83590
*                                                                       TIC83600
*                                                                       TIC83610
INITDELBAD RES     0                                                    TIC83620
         B         INITDELBADMESS
         PAGE                                                           TIC83650
*                                                                       TIC83660
*                                                                       TIC83670
*                                                                       TIC83680
INITDEL900 RES     0                                                    TIC83690
         M:SETDCB  F:DELX,(ERR,INITDEL902),(ABN,INITDEL902)             TIC83700
         M:CLOSE   F:DELX                                               TIC83710
INITDEL902 RES     0                                                    TIC83720
         PAGE                                                           TIC83730
*                                                                       TIC83740
*        FIRST PASS OVER M:SI DATA BUILDS TABLE SPACE.                  TIC83750
*                                                                       TIC83760
         LI,12     0                   COUNT OF DEV-TASKS.              TIC83770
         LI,13     0                   COUNT OF MDL-TASKS.              TIC83780
         LI,14     0                   NO MDL LINEIDS IN INITBUF3 YET.  TIC83790
*                                                                       TIC83800
INITMSI110 RES     0                                                    TIC83810
         M:READ    M:SI,(BUF,INITBUF2),(SIZE,80),;                      TIC83820
                   (ERR,INITMSIERR),(ABN,INITMSIABN)                    TIC83830
*                                                                       TIC83840
         LW,7      M:SI+4              GET ARS.                         TIC83850
         SLS,7     -17                 JUSTIFY ARS.                     TIC83860
*                                                                       TIC83870
         M:WRITE   F:MYSI,(BUF,INITBUF2),(SIZE,*7),;                    TIC83880
                   (ERR,INITFSIOUTERR),(ABN,INITFSIOUTERR)              TIC83890
*                                                                       TIC83900
*        R7 STILL HAS RECORD LENGTH.                                    TIC83910
*                                                                       TIC83920
         LI,6      4*INITBUF2          SET SCAN POINTER.
         AI,7      4*INITBUF2          SET END-OF-SCAN.
*                                                                       TIC83950
         FIELD6789POINTTOSTRING     SKIP ACQUIRE/TABLE/SWITCH FIELD.
         FIELD6789LOADAAAA             GET LINEID FIELD.                TIC83970
         LI,#ARG   1                   ISOLATE SECOND
         LB,9      8,#ARG               BYTE OF LINEID.
         CI,9      ':'                 IS IT A COLON.
         BE        INITMSI180          LOCAL (NOT MULTIPOINT) IF SO.
*
         LB,9      8                   ISOLATE FIRST BYTE.              TIC83980
         CI,9      'M'                 IS IT MULTIPOINT?                TIC83990
         BNE       INITMSI150          OVER IF NOT.                     TIC84000
*                                                                       TIC84010
*        FALL THROUGH IF MULTIPOINT.                                    TIC84020
*                                                                       TIC84030
*        MULTIPOINT LINE ID IS IN R8.                                   TIC84040
*                                                                       TIC84050
         LW,5      14                  COPY CURRENT # OF MULTIPOINTS.   TIC84060
         BEZ       INITMSI130          OVER IF NONE.                    TIC84070
*                                                                       TIC84080
         CW,8      INITBUF3,5          SEE IF LINEID                    TIC84090
         BE        INITMSI135           ON PREVIOUS                     TIC84100
         BDR,5     %-2                   M:SI CARD.                     TIC84110
*                                                                       TIC84120
*        FALL THROUGH ON NEW MULTIPOINT LINE.                           TIC84130
*                                                                       TIC84140
INITMSI130 AI,14   1                   BUMP INTO TABLE.                 TIC84150
         LW,5      14                  STORE NEW LINEID                 TIC84160
         STW,8     INITBUF3,5          INTO THE TABLE.                  TIC84170
*                                                                       TIC84180
         AI,13     1                   BUMP MDL-TASK COUNT              TIC84190
*                                                                       TIC84200
INITMSI135 RES     0                                                    TIC84210
*                                                                       TIC84220
INITMSI150 RES     0                                                    TIC84230
INITMSI180 RES     0
         AI,12     1                   BUMP DEV-TASK COUNT.             TIC84240
         B         INITMSI110          AND LOOP.                        TIC84250
*                                                                       TIC84260
*                                                                       TIC84270
*                                                                       TIC84280
INITMSI200 RES     0                   HERE AFTER READING ALL OF M:SI.  TIC84290
*                                                                       TIC84300
*        HERE AFTER COUNTING ALL STATIONS.
*
         LI,8      0                   CALCULATE TASK-NUMBER OF         TIC84310
         SW,8      13                   BIGGEST MDL-TASK WE HAVE.       TIC84320
         STW,8     #BIGGEST#MDL#TASK   AND REMEMBER IT.                 TIC84330
*                                                                       TIC84340
*        WHEN HERE, R12 HAS NUMBER OF DEV-TASKS TO BUILD TABLES FOR.    TIC84350
*        R13 HAS NUMBER OF MDL-TASKS TO BUILD TABLES FOR.               TIC84360
*                                                                       TIC84370
         AI,12     0                   SEE IF ANY DEV-TASKS.
         BGZ       INITMSI265          OVER IF SO.
*
*O*  MESSAGE:     'NO STATIONS'
*O*  ACTION:      CHECK ASSIGNMENT OF M:SI INPUT TO TIC.
*O*  MEANING:     NO STATIONS WERE FOUND IN READING M:SI FILE
*O*               CONTAINING ACQUIRE/TABLE INFORMATION INPUT TO THE TIC.
         #TYPE89   'NO STATIONS'
         M:XXX
*
INITMSI265 RES     0
*                                                                       TIC84420
MAKEATABLE CNAME                                                        TIC84430
         PROC                                                           TIC84440
AG       SET       AF                                                   TIC84450
         LI,10     AG(2)
         BAL,11    MAKEATABLECODE
         STW,4     AG(1)
         PEND                                                           TIC84700
*
*
*
         MAKEATABLE #DEV#RECORD#BA                                      TIC84710
         MAKEATABLE #DEV#RECORD#LENGTH                                  TIC84720
         MAKEATABLE #DEV#RECORD#STATUS                                  TIC84730
         MAKEATABLE #DEV#EVENT#PTR                                      TIC84740
         MAKEATABLE #DEV#DCB#POINTER                                    TIC84750
         MAKEATABLE #DEV#CURRENT#IO                                     TIC84760
         MAKEATABLE #DEV#INPUT#TRL                                      TIC84770
         MAKEATABLE #DEV#OUTPUT#TRL                                     TIC84780
         MAKEATABLE  #DEV#MDL#RETRY
         MAKEATABLE #MDL#WAKEUP#ECB                                     TIC84790
         DO        DO#FIXEDMDLBUFFERS
         MAKEATABLE #MDL#FIXED#BUFFERS
         FIN
         MAKEATABLE #MDL#TASK#ORDER
         MAKEATABLE #DEV#COMMAND#LINE#RECORD#BA                         TIC84810
         MAKEATABLE #DEV#COMMAND#LINE#RECORD#LENGTH                     TIC84820
         MAKEATABLE #DEV#LINE#IDENTIFIER                                TIC84830
         MAKEATABLE #DEV#MULTIPOINT#INDEX                               TIC84840
         MAKEATABLE #DEV#LINE#STATUS#BITS                               TIC84850
         MAKEATABLE #DEV#TYPE#INDEX
         MAKEATABLE #DEV#REGULATION                                     TIC84855
         MAKEATABLE #DEV#STATION#TYPE                                   TIC84860
         DO       DO#3270
         MAKEATABLE  #DEV#PLATEN#R
         MAKEATABLE  #DEV#PLATEN#C
         MAKEATABLE  #DEV#TC#RETRY
         FIN
         DO        HOWMANYXMITSBREAK>1
         MAKEATABLE #DEV#XMIT#COUNT
         FIN
         MAKEATABLE #DEV#ECB                                            TIC84870
         MAKEATABLE #DEV#LOGON#BLOCK                                    TIC84880
         MAKEATABLE #DCB#TABLE                                          TIC84885
*
*        WHILE WE KNOW HOW MANY DEV-TASKS AND
*        HOW MANY MDL-TASKS WE HAVE, WE GET
*        SPACE TO HOLD THE LONGEST POSSIBLE
*        ECB LIST THAT WE MIGHT WAIT ON.
*
         LW,5      12                  ONE ECB PER DEV-TASK
         AW,5      13                  AND TWO ECBS
         AW,5      13                   PER MDL-TASK.
         STW,5     ECBLISTMAXSIZE      REMEMBER MAX NUMBER OF ECBS.
         AI,5      1                   ROUND UP TO
         SLS,5     -1                   DOUBLEWORDS
         BAL,#BAL  #FIND#DWS           GET THE DWS.
         BEZ       INITNOPAGES          OUT IF NONE.
         SLS,4     1                   (DA TO WA)
         STW,4     ECBLISTWA           REMEMBER WHERE TO BUILD ECB LIST.
*                                                                       TIC84890
*                                                                       TIC84900
*                                                                       TIC84910
INITMSI290 RES     0                                                    TIC84920
         M:PFIL    F:MYSI,(BOF)                                         TIC84930
*                                                                       TIC84940
*                                                                       TIC84950
*                                                                       TIC84960
*                                                                       TIC84970
*        SECOND PASS OFER THE M:SI DATA.                                TIC84980
*                                                                       TIC84990
INITMSI500 RES      0                                                   TIC85000
          LI,#DEV   0                   WE DO DEV-TASKS IN ORDER.       TIC85010
INITMSI510 RES      0                                                   TIC85020
         M:READ    F:MYSI,(BUF,INITBUF2),(SIZE,80),;
                   (ERR,INITMSIERR510),(ABN,INITMSIABN510)
*
*        IF THE READ FALLS THROUGH, THEN WE GOT THE NEXT DEV-TASKS RECOR
*
         AI,#DEV   1
*
*
*
         LI,8      0                   ZERO OUT SOME TABLES:
         ##TPUT,8 #DEV#RECORD#BA
         #T#PUT,8  #DEV#RECORD#LENGTH
         #T#PUT,8  #DEV#RECORD#STATUS
         #T#PUT,8  #DEV#EVENT#PTR
         #T#PUT,8  #DEV#CURRENT#IO
         #T#PUT,8  #DEV#COMMAND#LINE#RECORD#BA
         #T#PUT,8  #DEV#COMMAND#LINE#RECORD#LENGTH
         #T#PUT,8  #DEV#LINE#STATUS#BITS
         #T#PUT,8  #DEV#TYPE#INDEX
         #T#PUT,8  #DEV#REGULATION
         #T#PUT,8  #DEV#LOGON#BLOCK
         #T#PUT,8  #DEV#DCB#POINTER
         DO       DO#3270
         #T#PUT,8  #DEV#PLATEN#R
         #T#PUT,8  #DEV#PLATEN#C
         FIN
         DO        HOWMANYXMITSBREAK>1
         #T#PUT,8  #DEV#XMIT#COUNT
         FIN
         #T#POST   #DEV#ECB
*
         LI,6      4*INITBUF2          SET SCAN OF CHARACTERS.
         LW,7      F:MYSI+4            GET AND                          TIC85080
          SLS,7     -17                  JUSTIFY ARS.                   TIC85090
          AW,7      6                   PLUS START IS END+1.            TIC85100
*                                                                       TIC85110
   FIELD6789BRANCHIF,INITMSIBAD INITMSI555,'A','C','Q','U','I','R','E'  TIC85150
   FIELD6789BRANCHIF,INITMSIBAD INITMSI550,'T','A','B','L','E'          TIC85160
     FIELD6789BRANCHIF,INITMSIBAD   INITMSI540,'S','W','I','T','C','H'
INITMSIBAD RES     0                                                    TIC85170
         LW,8      INITBUF2
         LW,9      INITBUF2+1
*O*  MESSAGE:     'BAD M:SI RECORD: '
*O*  ACTION:      CHECK SYNTAX OF ACQUIRE/TABLE INFORMATION.
*O*  MEANING:     ERROR FOUND IN TIC ACQUIRE/TABLE DATA SCAN SUCH AS:
*O*               KEYWORD NOT ACQUIRE OR TABLE; ^ MISSING BEFORE HEX CHAR.
         #TYPE89   'BAD M:SI RECORD: '
         M:XXX
*                                                                       TIC85200
INITMSI540  RES  0                  HERE ON SWITCH.
         FIELD6789LOADAAAA,INITMSIBAD          GET THE LINE ID.
         #T#PUT,8   #DEV#LINE#IDENTIFIER       STORE IT.
         LB,9     8                 ISOLATE 1ST BYTE OF LINE ID.
         CI,9     'C'               ONLY POINT-TO-POINT STNS MAY BE
         BE       INITMSI542          SWITCHED.
         #OUT     'SWITCH APPLIES ONLY TO POINT-TO-POINT STNS'
         B        INITMSIBAD
INITMSI542  RES  0
         #T#GET,12  #DEV#LINE#STATUS#BITS    SET NOT
         OR,12     =(#LINE#UNACQUIRED+#LINE#SWITCHABLE)
         #T#PUT,12  #DEV#LINE#STATUS#BITS      THE LINE.
         B        INITMSI660        SKIP THE LOCAL DEVICE & MDL TESTS.
INITMSI550 RES     0                    HERE ON TABLE.                  TIC85210
         #T#GET,12 #DEV#LINE#STATUS#BITS SET TO NOT                     TIC85220
          OR,12     =#LINE#UNACQUIRED    ACQUIRE                        TIC85230
         #T#PUT,12 #DEV#LINE#STATUS#BITS THE LINE.                      TIC85240
*                                                                       TIC85250
INITMSI555 RES      0                   HERE ON ACQUIRE.                TIC85260
          FIELD6789LOADAAAA,INITMSIBAD GET THE LINEID.                  TIC85270
          #T#PUT,8 #DEV#LINE#IDENTIFIER STORE IT.                       TIC85280
*
         LI,#ARG   1                   GET SECOND CHARACTER
         LB,9      8,#ARG               OF IDENTIFIER.
         CI,9      ':'                 COLON MEANS LOCAL.
         BNE       INITMSI590          OVER IF OT LOCAL.
*                                                                       TIC85290
*        FALL THRU ON LOCL DEVICE ON M:SI RECORD.
*
         CW,8      ='M:EO'             SEE IF KNOWN OUTPUT DEVICE.
         BNE       INITMSI582          OVER IF NOT.
*
         LI,9      #LINE#CANNOT#INPUT  LOAD APPROPRIATE LINE STATUS.
         LI,10     M:EO                LOAD DCB ADDRESS.
         BNEZ      INITMSI586          AND JOIN COMMON STORES.
         B         INITMSIBAD          (ERROR IF NO DCB)
*
INITMSI582 RES     0
         CW,8      ='M:EI'             SEE IF KNOWN INPUT DEVICE.
         BNE       INITMSIBAD          BAD RECORD IF UNKNOWN LOCAL NAME.
*
         LI,9      #LINE#CANNOT#OUTPUT LOAD APPROPRIATE LINE STATUS.
         LI,10     M:EI                LOAD DCB ADDRESS.
         BEZ       INITMSIBAD          (ERROR IF NO DCB)
*
INITMSI586 RES     0
         #T#PUT,9  #DEV#LINE#STATUS#BITS STORE TYPE OF UNIT RECORD
         LI,9      #DEV#TYPE#INDEX#UNIT#RECORD AND STORE UNIT
         #T#PUT,9  #DEV#TYPE#INDEX              RECORD INDEX.
         STW,10    *#DCB#TABLE#IW,#DEV AND STORE DCB ADDRESS IN
         #T#PUT,#DEV #DEV#DCB#POINTER   TABLE AND POINT TO IT.
         B         INITMSI660
*
INITMSI590 RES     0
          LB,9      8                   ISOLATE THE C OR M              TIC85300
          CI,9      'C'                 IS IT POINT-TO-POINT?           TIC85310
          BE        INITMSI660          OVER IF SO.                     TIC85320
         CI,9       'M'                 IS IT MULTI-POINT?              TIC85330
          BNE      INITMSIBAD           ERROR IF NEITHER.               TIC85340
*                                                                       TIC85350
*         FALL THROUGH ON 'M' TYPE LINE.                                TIC85360
*                                                                       TIC85370
*        LINE IDENTIFIER IS STILL IN R8.                                TIC85380
*                                                                       TIC85390
*        SCAN THROUGH THE LINEIDS IN INITBUF3                           TIC85400
*        TO FIND THIS GUYS MDL-TASK NUMBER.                             TIC85410
*                                                                       TIC85420
         LI,5      1                   START AT # ONE FOR TASK #S.      TIC85430
         CW,8      INITBUF3,5          SEE IF IDENTIFIER MATCHES.
         BE        INITMSI625                                           TIC85450
         AI,5      1                   OTHERWISE,                       TIC85460
         B         %-3                  LOOP LOOKING.                   TIC85470
*                                                                       TIC85480
INITMSI625 RES     0                                                    TIC85490
         LI,8      0                   MAKE R5 INTO CORRECT MDL-TASK    TIC85500
         SW,8      5                    NUMBER (THAT IS NEGATIVE).      TIC85510
         #T#PUT,8  #DEV#DCB#POINTER    AND STORE IT.                    TIC85520
*                                                                       TIC85530
*        NEED TO GET THE PHYSICAL ADDRESS AND                           TIC85540
*        PUT IT INTO THE #DEV TABLES.                                   TIC85550
*                                                                       TIC85560
         FIELD6789LOADAAAASKIP         GET PHYSICAL ADDRESS.
         LI,8      0                   OR LOAD A ZERO.
         #T#PUT,8  #DEV#LINE#IDENTIFIER AND STORE.
         B         INITMSI670
*
INITMSI660 RES      0                                                   TIC85640
         FIELD6789LOADAAAA,INITMSIBAD  IGNORE THE MDL ADDRESS.          TIC85650
*                                                                       TIC85660
INITMSI670 RES      0                                                   TIC85670
         FIELD6789LOADAAAASKIP         GET STATION TYPE.
         LI,8      X'0000'             OR USE DEFAULT.
         #T#PUT,8  #DEV#STATION#TYPE   STORE IT.
*                                                                       TIC85720
          FIELD6789LOADINTEGER,INITMSIDEFAULT5,INITMSIBAD GET IN-TRL.   TIC85730
          B         INITMSISTORE5                                       TIC85740
INITMSIDEFAULT5 LI,8 80                 DEFAULT RECORD SIZE = 80.       TIC85750
INITMSISTORE5 #T#PUT,8 #DEV#INPUT#TRL                                   TIC85760
*                                                                       TIC85770
          FIELD6789LOADINTEGER,INITMSIDEFAULT6,INITMSIBAD GET OUT-TRL.  TIC85780
          B         INITMSISTORE6                                       TIC85790
INITMSIDEFAULT6 LI,8 80                 DEFAULT RECORD SIZE = 80.       TIC85800
INITMSISTORE6 #T#PUT,8 #DEV#OUTPUT#TRL                                  TIC85810
*
         FIELD6789LOADINTEGER,INITMSIDEFAULT7,INITMSIBAD GET TYPE INDEX.
         B         INITMSISTORE7
INITMSIDEFAULT7 RES 0
         LI,8      3                   MAYBE TTY.
         #T#GET,#ARG #DEV#DCB#POINTER  SEE IF BI-POINT.
         BGEZ      INITMSISTORE7       MAYBE TTY IF BI-POINT.
         LI,8      3                   MAYBE TTY=VISTA IF MULTI-POINT.
INITMSISTORE7 RES  0
         #T#GET,#ARG #DEV#TYPE#INDEX   SEE IF ALREADY TYPED.
         BNEZ      INITMSI510          OVER IF SO.
         #T#PUT,8  #DEV#TYPE#INDEX     OR STORE TYPE.
         DO       DO#3270
         FIELD6789LOADINTEGER,INITMSIDEFAULT8,INITMSIBAD  GET MAX ROWS.
         B        INITMSISTORE8
INITMSIDEFAULT8  RES  0
         LI,8     24                DEFAULT MAX-ROWS = 24.
INITMSISTORE8  RES  0
         #T#PUT,8  #DEV#PLATEN#R
         FIELD6789LOADINTEGER,INITMSIDEFAULT9,INITMSIBAD  GET MAX COLS.
         B        INITMSISTORE9
INITMSIDEFAULT9  RES  0
         LI,8     80                DEFAULT MAX-COLS = 80.
INITMSISTORE9  RES  0
         #T#PUT,8  #DEV#PLATEN#C
         FIN
          B         INITMSI510                                          TIC86000
*                                                                       TIC86010
*                                                                       TIC86020
*                                                                       TIC86030
INITMSI800 RES     0                   HERE WHEN ALL DEV-TASKS INITIALIZ
INITMSI805 RES     0                                                    TIC86060
          STW,#DEV #BIGGEST#TIC#TASK    REMEMBER TOP TSSK NUMBER.       TIC86070
          B         INITMSI900                                          TIC86080
         PAGE                                                           TIC86090
*                                                                       TIC86100
*                                                                       TIC86110
*                                                                       TIC86120
INITMSIERR RES      0                                                   TIC86130
INITMSIABN RES      0                                                   TIC86140
         LB,8      10                   NEATEN THE ERR/ABN CODE.        TIC86150
          CI,8      6                   IS IT A E-O-F?                  TIC86160
         BE        INITMSI200          GO BUILD TABLES ON E-O-F.        TIC86170
*                                                                       TIC86180
*E*  MESSAGE:     'ERR/ABN ON M:SI'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN (OTHER THAN EOF) HAS
*E*               OCCURRED DURING READ OF M:SI TO SCAN ACQUIRE/TABLE
*E*               INFORMATION.
         #OUT      'ERR/ABN ON M:SI'
         M:XXX
*                                                                       TIC86210
INITMSIERR510 RES  0                                                    TIC86220
INITMSIABN510 RES  0                                                    TIC86230
         LB,8      10                  ISOLATE THE ERR/ABN CODE.        TIC86240
         CI,8      6                   IS IT AN E-O-F?                  TIC86250
         BE        INITMSI800          DONE IF END-OF-FILE.             TIC86260
*
INITFSIOUTERR RES  0
INITFSIOUTABN RES  0
*E*  MESSAGE:     'ERR/ABN ON F:MYSI'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN (OTHER THAN EOF) HAS
*E*               OCCURRED DURING WRITE OR READ OF F:MYSI, INTERNAL
*E*               VERSION OF M:SI.
         #OUT      'ERR/ABN ON F:MYSI'
         M:XXX
         PAGE
*
*
*
*        BAL'ED TO FROM THE MAKEATABLE PROC.
*
*        ENTER WITH:  R12 HAS NUMBER OF DEV-TASKS.
*                     R13 HAS NUMBER OF MDL-TASKS.
*                     R10 HAS NUMBER OF BYTES PER TABLE ENTRY.
*                     R11 IS BAL REGISTER.
*
*        RETURN WA OF ZERO'TH TABLE ENTRY IN R4.
*
*        MAY USE R9, R5, AND #ARG AND #BAL.
*        MAY USE R4 AND R8.
*
MAKEATABLECODE RES 0
         LW,5      12                  CALCULATE BYTES
         MW,5      10                   OF DEV SPACE ...
*                                      (WATCH USE OF ODD REGISTERS HERE)
         LW,9      13                  CALCULATE BYTES
         MW,9      10                   OF MDL SPACE, ROUNDED
         AI,9      3                     UP TO NEXT WORD.
         AND,9     =X'FFFFC'              (THIS STAYS IN R9)
         AW,5      9
         AW,5      10                  SPACE FOR ZERO'TH ENTRY.
         AI,5      7                   ROUND UP TO
         SLS,5     -3                   DOUBLEWORDS.
         BAL,#BAL  #FIND#DWS
         BEZ       INITNOPAGES
         SLS,4     1                   (DA TO WA)
         SLS,9     -2                  (BYTES OF MDL IN R9 TO WORDS)
         AW,4      9                   PLUS MDL SPACE POINTS TO ZERO'TH.
         B         *11                 AND RETURN.
          PAGE                                                          TIC86360
*                                                                       TIC86370
*                                                                       TIC86380
*                                                                       TIC86390
INITMSI900 RES      0                                                   TIC86400
         M:SETDCB  M:SI,(ERR,INITMSI902),(ABN,INITMSI902)               TIC86410
         M:CLOSE   M:SI                                                 TIC86420
INITMSI902 RES     0                                                    TIC86430
         M:SETDCB  F:MYSI,(ERR,INITMSI904),(ABN,INITMSI904)             TIC86440
         M:CLOSE   F:MYSI                                               TIC86450
INITMSI904 RES     0                                                    TIC86460
         PAGE                                                           TIC86470
*                                                                       TIC86480
*        NOW WE ACQUIRE LINES AND OPEN THEM:                            TIC86490
*                                                                       TIC86500
INITACQ100 RES     0                                                    TIC86510
         LW,#DEV   #BIGGEST#TIC#TASK   DO FOR ALL DEV-TASKS.            TIC86520
         BEZ       INITACQ900          OVER IF NONE TO ACQUIRE.         TIC86590
INITACQ110 RES     0                                                    TIC86600
*                                                                       TIC86610
         #T#GET,6  #DEV#DCB#POINTER    GET CURRENT DCB POINTER VALUE.
         BEZ       INITACQ205          OVER IF POINT-TO-POINT.
         BGZ       INITACQ305          OVER IF LOCAL DEVICE.
*                                      FALL THRU IF MULTIPOINT.
*                                                                       TIC86640
         LI,9      INITBUF3            POINT R9 TO IDENTIFIER
         SW,9      6                    IN THE BUFFER/LIST.             TIC86660
*                                                                       TIC86670
         LB,10     *9                  SEE IF FIRST TIME ENCOUNTERED.   TIC86680
         BEZ       INITACQ140          OVER IF NOT.                     TIC86690
*                                                                       TIC86700
         LW,11     *9                  RETRIEVE IDENTIFIER.             TIC86710
         #T#PUT,11,6 #DEV#LINE#IDENTIFIER REAL IDENTIFIER TO MDL'S ENTRYTIC86730
*                                                                       TIC86760
         LI,7      0                   SCAN                             TIC86770
         LW,10     #DCB#SREFS#WLIST,7   YABLE
         BLZ       INITACQOUTOFDCBS      AND GET                        TIC86790
         BGZ       %+3                    A DCB                         TIC86800
         AI,7      1                       FOR THE                      TIC86810
         B         %-4                      MDL-LINE.                   TIC86820
         LI,8      0                                                    TIC86830
         STW,8     #DCB#SREFS#WLIST,7
*                                                                       TIC86850
         STW,10    *#DCB#TABLE#IW,6    MDL-DCBS ONE-FOR-ONE WITH MDL-TASTIC86860
*                                                                       TIC86870
         #T#PUT,6,6 #DEV#DCB#POINTER
         #T#PUT,8,6 #DEV#INPUT#TRL
         ##TPUT,8 #DEV#RECORD#BA
         #T#PUT,8,6 #DEV#RECORD#LENGTH
         #T#PUT,8,6 #DEV#RECORD#STATUS
         #T#PUT,8,6 #DEV#EVENT#PTR
         #T#PUT,8,6 #DEV#CURRENT#IO
         #T#PUT,8,6 #DEV#COMMAND#LINE#RECORD#BA
         #T#PUT,8,6 #DEV#COMMAND#LINE#RECORD#LENGTH
         #T#PUT,8,6 #DEV#REGULATION
         #T#PUT,8,6 #DEV#LOGON#BLOCK
         #T#POST,8,6 #DEV#ECB
*
         LI,8      #LINE#UNACQUIRED
         #T#PUT,8,6 #DEV#LINE#STATUS#BITS
*                                                                       TIC87050
         LI,10     0                   SET IN INDEX TO M:LIST,          TIC87060
         STW,10    *9                   REPLACING THE IDENTIFIER.       TIC87070
*                                        (STARTS AT ONE, SEE BELOW)     TIC87080
*                                                                       TIC87090
*                                                                       TIC87100
*                                                                       TIC87110
INITACQ140 LW,13   *9                  BUMP TO                          TIC87120
         AI,13     1                    NEXT INDEX                      TIC87130
         STW,13    *9                    VALUE IN INITBUF3              TIC87140
         #T#PUT,13 #DEV#MULTIPOINT#INDEX  AND STORE.                    TIC87150
*
         #T#GET,8  #DEV#INPUT#TRL      STATION'S INPUT MESSAGE LENGTH.
         #T#GET,9,6 #DEV#INPUT#TRL     LINE'S INPUT BUFFER SIZE.
         CW,8      9                   COMPARE.
         BLE       INITACQ146          OVER ON WILL FIT.
         #T#PUT,8,6 #DEV#INPUT#TRL     OR MAKE BUFFER BIGGER.
INITACQ146 RES     0
*
         #T#GET,8  #DEV#OUTPUT#TRL     STATION'S OUTPUT MESSAGE LENGTH.
         #T#GET,9,6 #DEV#OUTPUT#TRL    LINE'S OUTPUT BUFFER SIZE.
         CW,8      9                   COMPARE.
         BLE       INITACQ149          OVER ON WILL FIT.
         #T#PUT,8,6 #DEV#OUTPUT#TRL    OR MAKE BUFFER BIGGER.
INITACQ149 RES     0
*                                                                       TIC87160
*        NOW PUT THE STATION INTO THE MDL-LINE'S LIST.                  TIC87170
*                                                                       TIC87180
         LW,8      *#DCB#TABLE#IW,6    LINE'S DCB LOCATION.             TIC87190
         #T#GET,11 #DEV#LINE#IDENTIFIER PHYSICAL ADDRESS OF STATION.    TIC87200
*                                      R13 STILL HAS 'INDEX'.           TIC87210
         M:MDFLST  *8,(PSL),(REPL,11,13)
         BCS,8     INITACQMDFLSTERROR
*
         #T#GET,9  #DEV#LINE#STATUS#BITS GET STATION'S STATUS.
         CI,9      #LINE#UNACQUIRED    SEE IF STATION ACQUIRED.
         BAZ       INITACQ160          GO AND ACQUIRE.
*
         M:MDFLST  *8,(PSL),(EXCL,13)  NO ACQUIRE -- EXCLUDE HIM.
         B         INITACQ400
*
INITACQ160 RES     0
*
         #T#GET,9,6 #DEV#LINE#STATUS#BITS GET ACQUIRED STATUS OF MDL.
         CI,9      #LINE#UNACQUIRED    SEE IF LINE UNACQUIRED.
         BAZ       INITACQ400          OVER IF LINE ALREADY ACQUIRED.
*
         LW,8      *#DCB#TABLE#IW,6    GET DCB LOCATION.
         #T#GWA,9,6 #DEV#LINE#IDENTIFIER POINT TO LINEID.
*
         M:GETLINE *9                  GET THE MOC LINE
         BCS,8     INITACQERR          OVER IF COULDN'T.
         M:OPEN    *8,(LINE,*9),(ERR,INITACQERR),(ABN,INITACQABN)
         M:SETDCB  *8,(ERR,MOCLINEERR),(ABN,MOCLINEABN)
         #T#GET,9,6 #DEV#LINE#STATUS#BITS AFTER HAVING GOTTEN,
         AND,9     =(-#LINE#UNACQUIRED-1) SET THE LINE ACQUIRED.
         #T#PUT,9,6 #DEV#LINE#STATUS#BITS
*
         B         INITACQ400                                           TIC87240
*                                                                       TIC87250
*
*
*        HERE WHEN NOT MULTI-POINT.
*
INITACQ205 RES     0                                                    TIC87260
         LI,7      0                   SCAN HERE TO GAT A DCB           TIC87270
         LW,9      #DCB#SREFS,7         FOR THE DEV-TASK.               TIC87280
         BLZ       INITACQOUTOFDCBS    ERROR IF OUT OF DCBS.            TIC87290
         BGZ       INITACQ220           OUT IF FOUND ONE.               TIC87300
         AI,7      1                   OTHERWISE,                       TIC87310
         B         %-4                  WE LOOP.                        TIC87320
*                                                                       TIC87330
INITACQ220 RES     0                   HERE WITH DCB FROM THE LIST OF   TIC87340
*                                      DCBS IN R9 AND WITH R7 STILL     TIC87350
*                                      POINTING INTO THE LIST OF THEM.  TIC87360
         LI,8      0                   CLEAR THE DCB SO THE NEXT        TIC87370
         STW,8     #DCB#SREFS,7         GUY WON'T GET IT.               TIC87380
*                                                                       TIC87390
         STW,9     *#DCB#TABLE#IW,#DEV FOR NOW, DCB TABLE               TIC87400
         #T#PUT,#DEV #DEV#DCB#POINTER   IS ONE-FOR-ONE WITH TASK NUMBER.TIC87410
*                                                                       TIC87420
          #T#GET,8 #DEV#LINE#STATUS#BITS GET STATUS BITS.               TIC87430
         CI,8      #LINE#UNACQUIRED    SEE IF 'TABLE' RATHER THAN 'ACQUITIC87440
         BANZ      INITACQ400          OVER IF SO.                      TIC87450
*                                                                       TIC87460
         #T#GET,8  #DEV#LINE#IDENTIFIER GET LINEID OF TASK.             TIC87470
         BEZ       INITACQ400          SPECIAL OVER IF NONE.            TIC87480
*                                                                       TIC87490
         #T#GWA,8  #DEV#LINE#IDENTIFIER POINT TO LINEID.                TIC87500
         M:GETLINE *8                  ACQUIRE THE INDICATED LINE.      TIC87510
         BCR,8     INITACQ270          OVER IF GETLINE OK.
*
*        FALL THROUGH WHEN WE COULD NOT
*        ACQUIRE THE BI-POINT LIN.
*
         #T#GET,8  #DEV#LINE#IDENTIFIER
*O*  MESSAGE:     'UNABLE TO ACQUIRE LINE:'
*O*  ACTION:      CHECK LINE-ID ON ACQUIRE COMMANDS FOR
*O*               BI-POINT LINES.
*O*  MEANING:     TIC COULD NOT ACQUIRE BI-POINT LINE SPECIFIED ON
*O*               ACQUIRE COMMAND.
         #TYPE89   'UNABLE TO ACQUIRE LINE:'
*
         #T#GET,8  #DEV#LINE#STATUS#BITS SET UNACQUIRABLE LINE
         OR,8      =#LINE#UNACQUIRED      TO UNACQUIRED (TABLED)
         #T#PUT,8  #DEV#LINE#STATUS#BITS   IN OUR TABLE.
         B         INITACQ400
*
INITACQ270 RES     0
          #T#GET,4 #DEV#DCB#POINTER     RE-ACQUIRE STATION'S            TIC87540
         LW,8       *#DCB#TABLE#IW,4     DCB LOCATION.                  TIC87550
         #T#GWA,9  #DEV#LINE#IDENTIFIER POINT TO LINEID.                TIC87560
         M:OPEN    *8,(LINE,*9),(ERR,INITACQERR),(ABN,INITACQABN)       TIC87570
         M:SETDCB  *8,(ERR,COCLINEERR),(ABN,COCLINEABN)                 TIC87580
         M:PURGE   *8                  CLEAR OUT ANY TYPE-AHEAD.        TIC87590
         B         INITACQ400          AND GO TO BDR.
*
*
*
INITACQ305 RES     0                   HERE ON LOCAL DEVICE.
         #T#GET,4  #DEV#DCB#POINTER
         LW,8      *#DCB#TABLE#IW,4
*
         M:OPEN    *8,(ERR,INITACQERR),(ABN,INITACQABN)
         M:SETDCB  *8,(ERR,COCLINEERR),(ABN,COCLINEABN)
*
*
*                                                                       TIC87600
INITACQ400 RES     0                                                    TIC87610
         BDR,#DEV  INITACQ110          DO ALL THE DEV-TASKS.            TIC87620
         B         INITACQ900          THEN WE'RE DONE.                 TIC87630
         PAGE                                                           TIC87640
INITACQERR RES     0                                                    TIC87650
INITACQABN RES     0                                                    TIC87660
*E*  MESSAGE:     'BAD LINE OPENING'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN ON M:OPEN OF BI-POINT LINE.
         #OUT      'BAD LINE OPENING'
         M:XXX
*                                                                       TIC87690
*                                                                       TIC87700
*                                                                       TIC87710
*                                                                       TIC87720
INITACQCOULDNOT RES 0                  HERE ON ERROR IN M:GETLINE.      TIC87730
         #SNAP     'ERROR RETURN FROM M:GETLINE'                        TIC87740
         B         INITACQ400                                           TIC87750
*                                                                       TIC87760
*                                                                       TIC87770
*                                                                       TIC87780
*                                                                       TIC87790
INITACQOUTOFDCBS RES 0                                                  TIC87800
*E*  MESSAGE:     'NEED MORE DCBS'
*E*  DESCRIPTION: TOO FEW DCBS WERE SUPPLIED WHEN TIC WAS LOADED TO
*E*               ALLOW FOR NO. NEEDED FOR THIS JOB'S BI-POINT AND/OR
*E*               MULTI-POINT LINE REQUIREMENTS.
         #OUT      'NEED MORE DCBS'
         M:EXIT
*                                                                       TIC87870
*                                                                       TIC87880
*                                                                       TIC87890
INITACQMDFLSTERROR RES 0                                                TIC87900
*E*  MESSAGE:     'BAD MODIFY LIST'
*E*  DESCRIPTION: ATTEMPT TO MODIFY POLLING/SELECTION LIST BY ADDING
*E*               A STATION TO POLLING LIST FAILED
         #OUT     'BAD MODIFY LIST'
         M:XXX
*                                                                       TIC87930
         PAGE                                                           TIC88190
INITACQ900 RES     0                                                    TIC88200
         PAGE
INITLAST RES       0
         M:FVP     INITBUF2            FREE UP THE FOUR PAGES
         M:FVP     INITBUF3             IN THE BOONDOCKS
         M:FVP     INITBUF4              THAT INIT WAS USING
         M:FVP     INITBUF5               FOR VARIOUS BUFFERING.
*
         CAL1,8    =X'15000004'        AND THEN REMOVE THOSE
         BCS,8     -1                   FOUR PAGES FROM OUR LIMIT.
*
         M:GETID                       GET AN ID.
         AI,8      0                   SEE IF IT IS ZERO.
         BNEZ      INITLAST233         OVER IF OK.
*
*O*  MESSAGE:     'ID IS ZERO: FIX BEFORE DOING NET ON'
*O*  ACTION:      MAKE SURE THAT TP WAS STARTED UP PRIOR TO START
*O*               OF TIC EXECUTION.
*O*  MEANING:     ATTEMPT BY TIC TO GET UNIQUE ID FOR A TRANSACTION
*O*               YIELDED ID OF ZERO; GENERALLY INDICATES THAT TP HAS
*O*               NOT BEEN STARTED UP.
         M:TYPE    (MESS,INITIDISZEROTEXTC)
*
INITLAST233 RES    0
         M:TYPE    (MESS,INITRUNNINGTEXTC)
*
*
*
         CAL1,9   11                GIVE BACK FILE BLOCKING BUFFERS FOR CP-V
*
*
*
         B         #TIC#BEGIN
*
*
*
INITIDISZEROTEXTC TEXTC 'ID IS ZERO: FIX BEFORE DOING NET ON'
INITRUNNINGTEXTC TEXTC 'TIC IS INITIALIZED'
         PAGE
*
*
*
INITNOPAGES RES    0
*E*  MESSAGE:     'INIT COULD NOT GET PAGE - INCREASE LIMIT'
*E*  DESCRIPTION: VIRTUAL PAGES AVAILABLE INSUFFICIENT.
         #OUT      'INIT COULD NOT GET PAGE - INCREASE LIMIT'
         M:EXIT
         PAGE
*        ERR/ABN ROUTINE FOR TICI FILE.
*        IT IS BACK HERE SO IT ISN'T FREED
*        EARLY IN INITIALIZATION.
*
INITTICIERR RES    0
INITTICIABN RES    0
*E*  MESSAGE:     'ERROR WRITING THE INTERNAL FILE'
*E*  DESCRIPTION: ERROR OR ABNORMAL RETURN WRITING F:TICI.
         #OUT      'ERROR WRITING THE INTERNAL FILE'
         M:XXX
         END

