         TITLE    'CMD-B00,09/20/73,DWG702985'
         SYSTEM   SIG7F
         CSECT    1
         PCC      0                 CONTROL CARDS NOT PRINTED.
CMD@     RES      0  ORIGIN OF CMD MODULE W/HOOKS TO WSCOPY & UTSC MODS.
*
*  REF'S  AND  DEF'S
*
         DEF      CMD@              = START OF 'CMD' MODULE.
         DEF      @OFF              OFF COMMAND PROCESSOR.
         DEF      KCLEAR            CLEAR COMMAND PROCESSOR.
         DEF      @CLEAR            CLEAR CMD ASSUMED, CLEARS WORKSPACE.
         DEF      SETFREET          SET-UP FREE TABLE
         DEF      @SAVE             SAVE COMMAND PROCESSOR.
         DEF      SAVEOPEN          OPEN FOR SAVE
         DEF      SAVEREL           RESUME AFTER CODESTR'G AUTOSTART.
         DEF      UNSYMS            GETS NO.OF UNUSED SYMBOLS.
         DEF      WRITEWS           ROUTINE TO WRITE WS ONTO FILE
         DEF      CMDRETRN          RETURN TO CMD MODULE.
         DEF      @LOAD             LOAD COMMAND PROCESSOR
         DEF      LOADCONT          LOAD CONTINUE WS AT START-UP.
         DEF      READWS            ROUTINE TO READ WS FROM FILE
         DEF      ACCTCHK           ACCOUNT CHECK ROUTINE               17-00001
         DEF      @WSID             WSID COMMAND PROCESSOR.
         DEF      @DROP             DROP COMMAND PROCESSOR.
         DEF      @COPY             COPY COMMAND PROCESSOR.
         DEF      @PCOPY            PCOPY COMMAND PROCESSOR.
         DEF      @LIB              LIB COMMAND PROCESSOR.
         DEF      @SYMBOLS          SYMBOLS COMMAND PROCESSOR.
         DEF      @OPRN             OPRN COMMAND PROCESSOR.
         DEF      @OPR              OPR COMMAND PROCESSOR.
         DEF      @TERM             TERMINAL COMMAND PROCESSOR.
         DEF      @TABS             TABS COMMAND PROCESSOR.
         DEF      @CONTINU          CONTINUE COMMAND PROCESSOR.
         DEF      CONTOFF           'CONTINE'-OFF
 SPACE 2
*                               REFS TO PROCEDURE:
         REF      ACQIT             ACQUIRES NAME OR NUMERIC ITEM.
         REF      ACQNB             ACQUIRES NON-BLANK, MAY BE ON IT NOW
         REF      ACQNXCC           ACQUIRES NEXT CHAR & ITS CODE.
         REF      ACQNXNB           ACQUIRES NEXT NON-BLANK CHAR.
         REF      BAQCONLY          ACQ. CONSTANT ONLY & RESUME IN CMD.
         REF      BCSN              CODESTRING & RESUME IN CMD.
         REF      B4CLOSE           FORCE CLOSE OF FN & RESUME IN CMD.
         REF      CALTIME           GET CURRENT TIME-DATE
         REF      CINTIM            CONVERT INTEGER TO IMAGE
         REF      CLEARMEM          CLEAR WS MEMORY TO MINIMUM
         REF      CLOSV             ROUTINE TO CLOSE DCB
         REF      CMDERR            COMMAND ERROR.
         REF      CMDEXIT           COMMAND EXIT.
         REF      COPY              PERFORMS COPY COMMAND.
         REF      DELAY6            DELAY 6 SECONDS
         REF      DREF              DEREFERENCE DATA BLK R4 PTS AT.
         REF      DROPFILE          ROUTINE TO DELETE FILE
         REF      DUMPLING          LINE OUTPUT ROUTINE
         REF      ERBADCMD          BAD COMMAND.
         REF      ERBDCMDA          BAD COMMAND WITH F:WS OPEN.
         REF      FNEQWSID          SET FID=WSID
         REF      GARBCOLL          GARBAGE COLLECT
         REF      GDIGITS           DIGITS FOR GRAPHICS SCALE
         REF      GENIS             GENERATES 'IS  ' & VALUE IN R7.
         REF      GENOPRM
         REF      GETCOM
         REF      GETDYN            GET DYNAMIC CORE
         REF      GETTERM           GET TERMINAL TRANSLATE TABLES
         REF      INPDIR            REQUESTS & HANDLES DIRECT INPUT.
         REF      LIBUTS            UTS INT. FOR )LIB PROCESSING
         REF      LOADREAD          READ A RECORD FOR LOAD
         REF      OPENSAVE          OPEN FILE FOR SAVE
         REF      OUTORANG          EXIT (DUAL) FOR COMMON CMDS.
         REF      QTABVLID          CHECK TAB VALIDITY
         REF      QUIETFLG          ZERO IF SAVED MSG IS TO BE DISPLAYED
         REF      RELEASER          RELEASE MEMORY AS POSSIBLE
         REF      RESACCT           RESET ACCOUNT
         REF      RESPASS           RESET PASSWORD
         REF      SAVEDMES          ISSUE SAVED MESSAGE AND EXIT
         REF      SAVWRITE          WRITE RECORD FOR SAVE
         REF      SETACCT           SET ACCOUNT
         REF      SETFNAME          SET FILE NAME
         REF      SETPASS           SET PASSWORD
         REF      SNEWTABS          SET NEW  TAB VALUES
         REF      STASHBL
         REF      TESTACCT          TEST ACCOUNT VS USERS'
         REF      TESTOLDF          TEST FOR OLD FILE EXISTENCE
         REF      TEXTC2I           MOVES TEXTC MSG TO IMAGE.
         REF      TRYLOAD           TRY TO START 'LOAD'
         REF      UTSIOFF           UTS INTERFACE ROUTINE FOR 'OFF'.
         REF      UTSIOFFH          UTS INTERFACE ROUTINE FOR 'OFF HOLD'
         REF      VALOUT            PUTS VALUE IN IMAGE, DISPLAYS, EXITS
         REF      WRTEXTC           WRITE TEXTC MESSAGE
         REF      XWLOCGLB          EXCHANGE LOCALS & GLOBALS.
*                               REFS TO CONTEXT:
         REF      BREAKFLG          BREAK OR 'HANGUP' FLAG
         REF      CLEARSIZ          SIZE OF 'CLEAR' PARAMETER TABLE
         REF      CATCHTBL          CATCH TBL.
         REF      CMNDTYPE          COMMAND TYPE
         REF      COMPRMST          START OF COMMON PARAMETERS TABLE
         REF      CONSTAD           ZERO-WD USED BY ACQCONST.
         REF      CONSTBUF          CONSTANT BUFFER
         REF      COPYSIZE          SET TO SIZE OF COPY WS DYNAMIC AREA.
         REF      CORAVAIL          AVAILABLE CORE (TOTAL)
         REF      CURRCS                CURRENT CODESTRING POINTER
         REF      DWIDTH            DEFAULT WIDTH
         REF      DYNBOUND          HIGHEST ADDR. IN DYNAMIC REGION.
         REF      ERRLOC            ERROR LOCATION.
         REF      ERRNUM            ERROR NUMBER.
         REF      ERRORID           INTERNAL ERROR I.D.
         REF      F:WS              F:WS DCB ADDRESS (MONITOR INTERFACE)
         REF      FREETBL           FREE TABLE (2-WD ITEMS-- LOC & AMT).
         REF      FREETOTL          TOTAL AMT OF FREE DYNAMIC SPACE.
         REF      GRAFPNTR          PTR TO SPECIAL D.B. FOR GRAPHICS.
         REF      HICOL             CHARACTER COUNT
         REF      HICOMMON          HIGHEST ADDR. IN COMMON REGION.
         REF      HOLDFLG           HOLD-OFF FLAG;FOR CONTINUE
         REF      IDBUF             TRYLOAD PUTS WS HEADER IN THIS BLK.
         REF      IMAGE             IMAGE BUFFER
         REF      IMAGEPOS
         REF      LOADCASE              LOAD CASE FLAG
         REF      LOCOMMON          LOW COMMON ADDRESS
         REF      LODACCT           LOAD-ACCOUNT
         REF      LODYN             LOWEST ADDR. IN DYNAMIC REGION.
         REF      MODE              EXECUTION MODE
         REF      NAMEBUF           HOLDS ITEM ACQUIRED BY ACQIT.
         REF      NEWBOUND          NEW DYNAMIC BOUND
         REF      NSYMTWDS          NO.OF WORDS IN SYM TBL (2X SYMTSIZE)
         REF      OBSFLAG           OBSERVE FLAG.
         REF      OBSERVE           OBSERVATION SETTING
         REF      ON%OFF            ON-LINE,OFF-LINE MODE FLAG
         REF      OPWSACT           WS ACCOUNT
         REF      OPWSNAME          WS NAME FOR 'OPEN'
         REF      OPWSPAS               WS PASSWORD
         REF      PCOPYFLG          PROTECTED COPY FLAG
         REF      QUITFLAG          FLAG TO CHECK REPEAT 'CONTINUE'
*                                   IN OFF-LINE MODE
         REF      SAVE312           SAVE AREA FOR APLINPUT
         REF      SICTRL            STATE-INDICATOR CONTROL FLAG.
         REF      STATEPTR          SI STATE POINTER
         REF      STRAYS            DATA BLK PTRS OUTSIDE THE WORKSPACE.
         REF      SYMT              LOC OF 1ST WD IN SYMBOL TABLE.
         REF      SYMTSIZE          NO.OF ENTRIES IN SYMBOL TABLE.
         REF      TABPNTR           TABSET INDICATOR
         REF      TABVALS             TAB VALUES (BYTES)
         REF      TERMTYPE          TERMINAL TYPE
         REF      TOPOSTAK          CURRENT ADDRESS-TOP OF EXEC. STACK
         REF      USERACCT          USER ACCOUNT NO.
         REF      WIDTH             PRINT WIDTH
         REF      WINDOW                 BUFFER FOR )LOAD
         REF      WSIDNAME              WORKSPACE NAME (TEXTC)
         REF      WSIDPASS              AND PASSWORD   (TEXT)
         REF      WSOFFSET              WORKSPACE OFFSET
*                               REFS TO CONSTANTS:
         REF      APLVERSN          VERSION ID
         REF      BITPOS            32-WD TBL OF BITS (ONLY BIT K IS = 1
*                                     IN THE WORD 'BITPOS-K').
         REF      BLANKS
         REF      CLEARWS           NAME-CLEAR WS
         REF      CMDB              = LOC OF CMD REC'S BRANCH TBL.
         REF      FFFFFE00          PAGE BOUND MASK
         REF      F0F9              '0'-'9'
         REF      ID2BIGLD          = ERROR I.D. FOR -- TOO BIG TO LOAD.
         REF      ISMSG             'IS  '
         REF      KEY1              1ST KEY VALUE
         REF      KONTINUE
         REF      MAXFRENS          = MAX NO.OF ENTRIES IN FREETBL.
         REF      NCMDS             = NO.OF COMMANDS IN CMD TBL.
         REF      NCOMPRMS          SIZE OF COMMON PARAMETERS TABLE
         REF      NONAME            NAME CHARACTER COMPARISON
         REF      STRAYBLK          = TOTAL NO.OF STRAY DATA BLK PTRS.
         REF      STACKOFF          = OFFSET FROM HI COMMON TO XEQ STACK
         REF      SYMTOFF           = OFFSET FROM LO DYNAMIC TO SYM TBL
         REF      WASMSG            'WAS '
         REF      ZEROZERO          ZEROS
         REF      @@CLEAR           = POS. IN CMD TBL FOR )CLEAR CMD.
         REF      @@CONT            = POS. IN CMD TBL FOR )CONTINUE CMD.
*
*  STANDARD EQU'S
*                   REGISTERS
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
*
*  OTHER EQU'S
*
 SPACE
NOMSYMS  EQU      261               NOMINAL # ENTRIES IN SYMBOL TABLE.
 SPACE
NEWLINE  EQU      X'15'             INTERNAL (EBCDIC) CHAR--END OF LINE.
         PAGE
*
*  CONSTANTS
*
FINAL    DATA     X'0A000000'       'FINAL' F-ENTRY (FUNCTION-STATE).
HOLD     TEXT     'HOLD'
*
* CLEARTBL-TABLE OF DEFAULT VALUES OF PARAMETERS FOR CLEAR WS
*  ****  THIS TABLE MUST CORRESPOND TO TABLE-COMPRMST  ******
*
*
         BOUND    8
CLEARTBL DATA     0,X'200'          FUZZBIT
         DATA     -X'35200000',X'35200000'   FUZZLIMS
         DATA     -X'400'           FUZZMASK
         DATA     10                FUZZCNT
         DATA     0                 ORGADJ
         DATA     1                 ORIGIN
         DATA     10                DIGITS
         DATA     120               WIDTH
         DATA     123456789         RANDOM
*
         PAGE
*
* @OFF AND @OFFHOLD-EXIT WITHOUT SAVING IN CONTINUE
*                   TO TEL(HOLD) OR SIGN-OFF
*
@OFF     AI,R2    -NEWLINE          OFF FOLLOWED BY END-OF-INPUT...
         BEZ      UTSIOFF             YES,  EXIT FROM SYSTEM.
         BAL,R14  ACQIT               NO, EXPECT TO ACQUIRE 'HOLD'...
         AI,R2    -NEWLINE
         BNEZ     ERBADCMD          GARBAGE
         LW,R8    HOLD
         CW,R8    NAMEBUF
         BE       UTSIOFFH             RIGHT ON
         B        ERBADCMD              OOPS -- INCORRECT COMMAND.
         PAGE
*
* @CLEAR-SET CLEAR WORKSPACE-EXIT TO INPDIR
*
KCLEAR   AI,R2    -NEWLINE          DID CLEAR I.D. END ON END-OF-INPUT.
         BNEZ     ERBADCMD            NO -- INCORRECT COMMAND.
@CLEAR   RES      0                   YES, CLEAR USER'S WORKSPACE.
         BAL,R11  CLEARMEM          CLEAR COMMON AND DYN-SET LIMITS
         LI,R1    NOMSYMS**1        = NO.OF WDS IN NOMINAL SYMBOL TABLE.
         STW,R1   NSYMTWDS
         LI,R1    NOMSYMS           = NO.OF ENTRIES IN NOMINAL SYM TBL.
SETSYMT  STW,R1   SYMTSIZE
         LI,R3    SYMTOFF           OFFSET FROM LODYN TO 1ST SYM TBL WD.
         STW,R3  *LODYN             THAT'S THE 1ST WD IN DYNAMIC.
         AW,R3    LODYN             PT AT 1ST WD OF SYMBOL TABLE.
         STW,R3   SYMT
         LI,R9    3
         STW,R9   GDIGITS          SET DIGITS FOR GRAPHICS
         LI,R9    -1
         STW,R9   CATCHTBL          CLEAR THE CATCH TABLE.
         STW,R9   CATCHTBL+2
         LW,R8    BITPOS-0          SET 'GLOBAL' BIT (ONLY).
         LI,R9    0           NOTE--R9 REMAINS ZERO THRUOUT CLEAR DRIVER
         STW,R9   ERRLOC            INIT ERROR LOCATION.
         STW,R9   ERRNUM                 ERROR NUMBER.
         STW,R9   ERRORID                INTERNAL ERROR I.D.
         STW,R9   OBSFLAG                OBSERVE FLAG.
         STW,R9   SICTRL                 STATE-INDICATOR CTRL = ON.
CLRSYMT  STW,R8   0,R3              INIT A REFERENT-INDICATOR WD &
         STW,R9   1,R3                   A NAME-INDICATOR WD.
         AI,R3    2                 PT AT WD AFTER CLEARED NAME-INDIC.
         BDR,R1   CLRSYMT           SET UP A CLEAR SYMBOL TABLE.
         LI,R5    SETSTOFF          SET EXIT                     @@@@@@@
*                                                                      @
* SETFREET-SET UP FREETABL AND FREETOTL,AND CLEAR STRAYS               @
*    R5=LINK  R3=1ST FREE ADDRESS                                      @
*             R3 IS CHANGED                                            @
*             R1,R8,R9 VOLATILE                                        @
*                                                                      @
SETFREET STW,R3   FREETBL           ROUTINE TO INITIALIZE FREETBL@@@@@@@
         LD,R8    ZEROZERO
         LI,R1    -MAXFRENS+1         (EXC 1ST ENTRY, OTHERS MUST BE 0).
CLRFRET  STD,R8   FREETBL+MAXFRENS+MAXFRENS,R1  CLEAR FREE TABLE, ALMOST
         BIR,R1   CLRFRET
         LW,R3    DYNBOUND          GET AMT OF FREE DYNAMIC.
         SW,R3    FREETBL
         STW,R3   FREETBL+1         SET SIZE-WD OF 1ST FREE TABLE ENTRY.
         STW,R3   FREETOTL          THAT'S THE TOTAL FREE DYNAMIC, TOO.
*
         STW,R9   CONSTAD           THIS CELL SHOULD ALWAYS BE ZERO.
*
         LI,R1    -STRAYBLK         = - TOTAL NO.OF STRAY DATA BLK PTRS.
CLRSTRAY STW,R9   STRAYS+STRAYBLK,R1  THESE DATA BLK PTRS HAVE TO BE 0,
         BIR,R1   CLRSTRAY              UNTIL THEY PT TO A DATA BLOCK.
         B        0,R5
*
SETSTOFF LI,R3    -STACKOFF         OFFSET FROM HICOMMON TO EXEC. STACK
         STW,R3  *HICOMMON          THAT'S THE LAST WD IN COMMON.
         AW,R3    HICOMMON          PT AT BEGINNING OF EXECUTION STACK.
         LW,R1    FINAL             SET 1ST STACK ENTRY TO BE THE
         STW,R1   0,R3                'FINAL' F-ENTRY.
         STW,R3   TOPOSTAK          SET STACK POINTER.
         STW,R3   STATEPTR          SET STATE POINTER.
         LI,R3    CLEARSIZ
SETCLEAR LW,R4    CLEARTBL-1,R3     INITIALIZE FUZZ,ORIGIN,DIGITS
         STW,R4   COMPRMST-1,R3      WIDTH,AND RANDOM SEED
         BDR,R3   SETCLEAR
         STD,R3   WSIDPASS              RESET WSID PASSWORD
         LW,R4    DWIDTH            SET WIDTH TO
         STW,R4   WIDTH              DEFAULT FOR TERMINAL
         LCI      3
         LM,R4    CLEARWS
         STM,R4   WSIDNAME
         LW,R4    USERACCT
         LW,R5    USERACCT+1        (NOT ON DW BOUND)
         STD,R4   LODACCT            RESET LOAD ACCOUNT ID
         LW,R8    CMNDTYPE          CHECK IF
         AI,R8    NCMDS-@@CLEAR+CMDB    REACHED BY CLEAR COMMAND
         BNEZ     OLDSYMS             NO-)SYMBOLS
CLEARWSM LI,R8    CLEARWS
         BAL,R7   WRTEXTC           ISSUE CLEAR WS MESSAGE
         LW,R7    BREAKFLG          CHECK FOR HANG-UP
         BLZ      UTSIOFFH           YES-QUIT
         B        INPDIR             GO TO DIRECT INPUT
         PAGE
*
* @SAVE-PROCESSOR FOR SAVE COMMAND
*
*       ENTERED ON RECOGNITION OF 'SAVE',WITH SCAN READY FOR NEXT ITEM
*
*        FINAL EXIT TO COMMON COMAND EXIT AFTER EXECUTION OF
*              COMMAND OR ERROR MESSAGE GENERATION
*
*       MOST REGISTERS USED-NONE PRESERVED
*
*
* LAYOUT OF WORKSPACE ID RECORD-1ST 13 WORDS
*
*      0-SYMTOFF
*      1-SYMTSIZE
*      2-FREETBL
*      3-TOPOSTAK
*      4-LODYN
*      5-HICOMMON
*      6-APLVERSN
*      7-APLVERSN+1
*      8-TIME
*      9-  AND
*     10-   DATE
*     11-    IN EBCDIC
*     12-CMNDTYPE OR CURRCS(IF NON-ZERO)-FLAG USED TO INDICATE
*        AUTOCONTINUE OR AUTOSTART
*
@SAVE    LI,R13   0
         STW,R13  ERRORID            CLEAR INTERNAL ERROR I.D.
         CI,R2    X'15'              CHECK FOR CR
         BE       NOFID              YES-NO FID
         BAL,R13  ACQFID             NO-ESTABLISH FID(OR QUIT)
SAVETACT BAL,R14  TESTACCT              CHECK IF USERS ACCOUNT
SAVECR   BAL,R14  TESTOLDF              TEST IF OLD FILE-IF SO,CHECK WSID
SAVEOPEN LW,R14   MODE              CHECK IF FUNCTION OPEN
         BNEZ     OPENOUT            NO
         CI,R2    X'5E'                CHECK IF SAVE FOR AUTOLOAD
         BE       ERBADCMD             YES-NOT PERMITTED
         BAL,R14  B4CLOSE             YES-FORCE CLOSE
OPENOUT  BAL,R14  QCLEAR            CHECK IF CLEAR WS
         BE       CLEARWSM           YES-DON'T SAVE
         BAL,R14  OPENSAVE
         BAL,R8   GARBCOLL          GARBAGE COLLECT
         CI,R2    X'5E'                 CHECK IF SAVE FOR AUTO-START
         BNE      SAVEREL                NO
         LI,R2    1                      YES
         CW,R2    MODE                    CHECK IF DIRECT INPUT MODE
         BNE      ERBDCMDA                 NO-ERROR
         BAL,R4   ACQNXNB               GET CHARACTER AFTER ';'
         CI,R2    X'7F'
         BE       ERBDCMDA              QUIT ON FUNCTION OPEN
         CI,R2    X'75'                  OR
         BE       ERBDCMDA                LOCKED FUNCTION OPEN
         CI,R2    X'5D'                    OR
         BE       ERBDCMDA                  COMMAND
         B        BCSN                  CODESTRING THE 'AUTOSTART' LINE
SAVEREL  BAL,R11  RELEASER               RELEASE UNUSED MEMORY
         BAL,R14  XWLOCGLB          SURFACE GLOBALS TO SYMBOL TABLE
         LI,R14   SAVEDONE
         LW,R12   KEY1               SET 1ST KEY FOR KEYED WRITES
         LI,R2    0                   SET TO INDICATE WRITE FOR )SAVE
WRITEWS  LI,R7    0                 ------------------------------------
         LI,R6    SYMTOFF-1         -  ZERO FIXED DYNAMIC REGION,      -
         STW,R7  *LODYN,R6          -    EXCEPT SYMTOFF (1ST WD).      -
         BDR,R6   %-1               ------------------------------------
         LD,R6    LODYN             LODYN AND HICOMMON
         LD,R8    APLVERSN           SET WORKSPACE DESCRIPTONS IN LODYN
         LW,R3    SYMTSIZE
         LW,R4    FREETBL
SAVTOPST LW,R5    TOPOSTAK
         LCI      7                 SET SYMTSIZE,FREETBL,TOPOSTAK,
         STM,R3   1,R6                  LODYN,HICOMMON,APLVERSN(DW)
         AI,R6    8
         BAL,R7   CALTIME           SET TIME AND DATE - 4 WORDS
         LW,R7    CURRCS                 GET CURRENT CODESTRING POINTER
         BNEZ     SAVECS                   SET AUTOSTART FLAG
         LW,R7    CMNDTYPE                 SET AUTOCONTINUE IF INDICATED
SAVECS   STW,R7   4,R6                      SAVE FLAG
         LI,R7    0                 ------------------------------------
         LI,R6    1-STACKOFF        -  ZERO FIXED COMMON REGION,       -
         STW,R7  *HICOMMON,R6       -    EXCEPT -STACKOFF (LAST WD).   -
         BIR,R6   %-1               ------------------------------------
         LW,R6    HICOMMON
         AI,R6    -1
         LI,R7    NCOMPRMS          NO. OF COMMON PARAMETERS
         STW,R7   0,R6               SAVE AT  HICOMMON-1
SCOMPRMS LW,R8    COMPRMST-1,R7       SAVE COMMON PARAMETERS
         AI,R6    -1
         STW,R8   0,R6
         BDR,R7   SCOMPRMS
         LW,R8    SICTRL            SAVE SI CTRL IN COMMON REGION.
         STW,R8   -1,R6   NOTE -- SICTRL SAVED AT HICOMMON - 17.
         LW,R8    GRAFPNTR
         STW,R8   -2,R6  NOTE -- GRAFPNTR SAVED AT HICOMMON - 18.
         LW,R8    GDIGITS
         STW,R8   -3,R6   NOTE -- GDIGITS SAVED AT HICOMMON -19.
*
         LW,R11   LODYN             GET ADDRESS FOR 1ST PAGE OUT
         LI,R10   2048              SET RECORD SIZE (USED BY COPY)
         LW,R13   TOPOSTAK            SET TEST
         AI,R13   -512                 FOR START OF COMMON
SAVLOOP1 CW,R11   FREETBL           CHECK IF PAGE IS IN DYNAMIC USE
         BGE      SAVLOOP4           NO
SAVLOOP2 BAL,R7   SAVWRITE,R2        YES-WRITE IT
         AI,R12   1                   UPDATE KEY
SAVLOOP3 AI,R11   512                  UPDATE ADDRESS-1 PAGE
         B        SAVLOOP1          CONTINUE
SAVLOOP4 CW,R11   R13               CHECK IF COMMON REACHED
         BLE      SAVLOOP3           NO
         CW,R11   HICOMMON           YES-CHECK IF DONE
         BL       SAVLOOP2           NO
CMDRETRN B       *R14               RESUME VIA R14.
SAVEDONE LCI      3
         LM,R6    OPWSNAME
         STM,R6   WSIDNAME          SET NEW WSID
         LD,R6    OPWSPAS
         STD,R6   WSIDPASS           AND PASSWORD
         LW,R6    USERACCT          RESET USERS ACCOUNT
         LW,R7    USERACCT+1         (NOT DW BOUND)
         STD,R6   LODACCT
         LI,R4    0                 RESET CURRCS AND TEST VALUE
         STW,R4   QUIETFLG            (CLEAR THE QUIET-FLAG, BE NOISY)
         XW,R4    CURRCS
         BEZ      SAVXW                  NO CODESTRING
         AI,R4    -2                     AUTOSTART CODESTRING EXISTS
         BAL,R7   DREF                     DEREFERENCE IT
SAVXW    BAL,R14  XWLOCGLB             RE-EXCHANGE LOCALS AND GLOBALS
         LI,R2    0                    SET WS OFFSET TO ZERO
LODEXIT  LI,R5    F:WS                 DCB ADDRESS
         BAL,R6   CLOSV             CLOSE THE SAVED FILE
         MTW,0    BREAKFLG           CHECK FOR 'HANGUP'
         BLZ      UTSIOFFH            YES-QUIT
         B        SAVEDMES           ISSUE 'SAVED' MESSAGE AND EXIT
NOFID    BAL,R14  RESACCT           RESET ACCOUNT
         BAL,R14  FNEQWSID            SET FID TO WSID
         B        SAVECR
         PAGE
*
* @LOAD-DRIVER TO LOAD A WORKSPACE (OR ERROR EXIT)
*
@LOAD    SW,R6    CMNDTYPE          SET QUIET-FLAG: -1 -- IF QUIET &
         STW,R6   QUIETFLG                            0 -- IF NOISY.
         BAL,R13  ACQFID            GET FILE IDENTIFICATION.
LOADCONT BAL,R14  TRYLOAD            TRY TO OPEN AND READ ID RECORD.
         LI,R2    0                    SET TO INDICATE READ FOR LOAD
         STW,R2   ERRORID             (CLEAR INTERNAL ERROR I.D.)
         LI,R14   NEWSID             SET EXIT FROM READWS
         LW,R3    KEY1                START WITH KEY1
READWS   LI,R8    ID2BIGLD          SET FOR 'TOO BIG TO LOAD' ERROR.
         STW,R14  HOLDFLG           SAVE R14 FOR RETURN
         LW,R10   2,R4
         SW,R10   4,R4                 'FREETBL'-'LODYN' FOR FILED WS
         AW,R10   5,R4
         SW,R10   3,R4                +'HICOMMON'-'TOPOSTAK'=TOTAL SPACE
         CW,R10   CORAVAIL             CHECK FOR FIT IN CORE
         BGE      CLOSV                 TOO BIG
         LW,R10   2,R4
         AI,R10   511
         AND,R10  FFFFFE00             ROUND 'FREETBL' UP TO PAGE BOUND
         LW,R9    3,R4
         AND,R9   FFFFFE00             ROUND 'TOPOSTAK' DOWN
         LI,R8    0                    INITIALIZE LOADCASE FLAG VALUE
         CW,R9    R10                  CHECK IF FILED WS SHARES PAGE
         BGE      NODUAL                OF DYNAMIC AND COMMON
         AI,R8    1                      YES-SET FLAG
NODUAL   STW,R8   LOADCASE              SAVE FLAG
         BAL,R11  CLEARMEM             CLEAR MEMORY
         AW,R9    HICOMMON          IN-CORE HICOMMON
         SW,R9    5,R4              'HICOMMON' FOR FILE
         LI,R14   FTCHCOMN          SET RETURN
FTCHCOMN CW,R9    LOCOMMON          CHECK IF COMMON PAGE(S) NEEDED
         BL       GETCOM             YES
         LW,R8    2,R4              'FREETBL'
         AW,R8    WSOFFSET             ADJUST FOR WS OFFSET
         STW,R8   NEWBOUND
         BAL,R14  GETDYN            GET DYNAMIC PAGES FOR LOAD
         CW,R8    DYNBOUND          CHECK AGAIN FOR OVERLAP
         BLE      SLODSIZ            NO
         STW,R8   DYNBOUND           YES-SET OVERLAP CONDITION
         STW,R8   LOCOMMON
         MTW,2    LOADCASE             SET FLAG FOR IN-CORE OVERLAP COND.
SLODSIZ  LI,R10   2048              SET RECORD SIZE (512 WORDS)
         LW,R11   LODYN             SET TO START LOAD
         LW,R12   R3                 SET 1ST KEY OR GRANULE #
LODLOOP1 CW,R11   NEWBOUND             ADJUSTED 'FREETBL'
         BGE      LODLOOP2              DYNAMIC PAGES ARE LOADED
         BAL,R14  LOADREAD,R2            READ A DYNAMIC RECORD
         AI,R12   1                       KICK KEY
         AI,R11   512                      UPDATE BUFFER ONE PAGE
         B        LODLOOP1                  LOOP
LODLOOP2 LW,R7    LOADCASE             CHECK WHICH LOAD CASE
         B        LODLOOP3,R7
LODLOOP3 B        LODOPEN              NO OVERLAPS
         B        LODXPAND             FILE OVERLAP,EXPAND IN CORE
         B        LODPACK              CORE OVERLAP,COMPRESS IN CORE
         B        LODCOMON             BOTH OVERLAP,LOAD COMMON PAGES
LODXPAND AI,R11   -512                 BACK UP 1 PAGE
         LW,R5    LOCOMMON             GET START OF COMMON
         LI,R14   256                  LOOP COUNTER
LODLOOP4 LD,R6   *R11                   MOVE LAST DYNAMIC PAGE
         STD,R6  *R5                     TO FIRST COMMON PAGE
         AI,R11   2
         AI,R5    2
         BDR,R14  LODLOOP4
         LW,R11   R5                   SET R11 FOR NEXT COMMON PAGE
         B        LODCOMON              AND LOAD REMAINING COMMON
LODPACK  STW,R11  LOADCASE             SAVE RECORD READ POINTER
         LI,R11   WINDOW
         BAL,R14  LOADREAD,R2          READ FIRST COMMON PAGE INTO
         AI,R12   1                     'WINDOW' AND UPDATE KEY
         LI,R14   X'1FF'
         AND,R14  3,R4                 GET PAGE OFFSET OF 'TOPOSTAK'
         LW,R5    LOADCASE
         AI,R5    -512                 GET START OF LAST DYNAMIC PAGE
         AW,R5    R14                    ADD TOPOSTAK OFFSET
         AW,R11   R14                    OFFSET 'WINDOW'
LODLOOP5 LW,R6   *R11                  MOVE THE USED PART OF COMMON
         STW,R6  *R5                    FROM WINDOW TO TARGET ADDRESSES
         AI,R5    1
         AI,R11   1
         CI,R11   WINDOW+511
         BLE      LODLOOP5
         LW,R11   LOADCASE             SET R11 FOR NEXT COMMON PAGE
         B        LODCOMON
LODOPEN  CW,R11   R9                   CHECK START OF COMMON
         BGE      LODCOMON              YUP
         AI,R11   512                    NO
         B        LODOPEN                 LOOP
LODCOMON CW,R11   HICOMMON             CHECK IF LOAD DONE
         BGE      LODFINI               YUP
         BAL,R14  LOADREAD,R2            NOPE-READ NEXT RECORD
         AI,R12   1                       KICK KEY
         AI,R11   512                      AND BUFFER ADDRESS
         B        LODCOMON
LODFINI  LI,R5    NCOMPRMS             LOAD DONE,SET COMMON PARAM. BOUND
         LW,R6    HICOMMON                AND INDEX IN HICOMMON
LCOMPRMS LW,R8    -2,R6
         STW,R8   COMPRMST-1,R5     MOVE COMMON PARAMETERS TO TABLE
         AI,R6    -1                 IN DATA REGION
         BDR,R5   LCOMPRMS
         LW,R5    HICOMMON
         SW,R5    5,R4              'HICOMMON' ON FILE
         AWM,R5   STATEPTR          ADJUST STACK
         AWM,R5   TOPOSTAK           POINTERS (IF NECESSARY)
         LW,R5    4,R4              'LODYN' FOR LOADED WS
         AW,R5    0,R4              SYMT OFFSET FOR LOADED WS
         AW,R5    WSOFFSET
         STW,R5   SYMT               SET SYMT ADDRESS
         LW,R5    1,R4              SET UP
         STW,R5   SYMTSIZE           SYMBOL TABLE
         SLS,R5   1                   SIZE
         STW,R5   NSYMTWDS
         LW,R3    NEWBOUND             ADJUSTED 'FREETBL'
         BAL,R5   SETFREET          SET UP FREETBL
         B       *HOLDFLG           (RETURN VIA SAVED R14)
NEWSID   LCI      3
         LM,R6    OPWSNAME
         STM,R6   WSIDNAME          SET WSID
         LD,R6    OPWSACT
         STD,R6   LODACCT           SET LOAD ACCOUNT
         LD,R6    OPWSPAS           SET WSID
         STD,R6   WSIDPASS           PASSWORD IF PRESENT
         LI,R14   -1
         STW,R14  CATCHTBL          CLEAR THE CATCH TABLE.
         STW,R14  CATCHTBL+2
         STW,R9   ERRLOC NOTE: R9=0 CLEAR ERROR LOCATION &
         STW,R9   ERRNUM ----  ----       ERROR NUMBER.
         STW,R9   OBSFLAG                 OBSERVE FLAG TOO.
         STW,R9   OBSERVE
         LW,R14   IDBUF+7           GET APLVERSN+1 FOR THE SAVED WS.
         CW,R14   SA02              CK AGAINST THE 'A02' VERSION...
         BGE      NEWSIDRX            A02 OR LATER.
*
*                                     ANCIENT WS ...
*
         LW,R6    LODYN             ------------------------------------
         AI,R6    13-1              -                                  -
         LI,R7    SYMTOFF-13        -  ZERO THOSE WDS OF FIXED DYNAMIC -
         STW,R9  *R6,R7             -  & FIXED COMMON THAT WERE UNUSED -
         BDR,R7   %-1               -  IN WORKSPACES PRIOR TO A02.     -
         LW,R6    HICOMMON          -                                  -
         AI,R6    1-17              -  NOTE--THIS CODE IS OK ONLY AS   -
         LI,R7    17-STACKOFF       -        LONG AS SYMTOFF = 20  &   -
         STW,R9  *R6,R7             -                STACKOFF = 32.    -
         BIR,R7   %-1               ------------------------------------
NEWSIDRX BAL,R14  XWLOCGLB          RE-EXCHANGE LOCALS & GLOBALS.
         LW,R6    HICOMMON
         LW,R2    -17,R6  NOTE --   GET SI CTRL FROM SAVED WS,
         STW,R2   SICTRL              HICOMMON - 17.
         LW,R2    -18,R6  NOTE --   GET GRAPHICS SPECIAL BLOCK PTR FROM
         STW,R2   GRAFPNTR            SAVED WS, HICOMMON - 18:
         LW,R2    -19,R6  NOTE --   GET GDIGITS FROM SAVED WS,
         BLEZ     %+2               DON'T USE IF OLD WS.
         STW,R2   GDIGITS
         LW,R2    IDBUF+12           CHECK FOR AUTOSTART
         BLEZ     SOFFSET             NO
         STW,R2   CURRCS              YES-SET CURRCS
SOFFSET  LW,R2    WSOFFSET            WS OFFSET
         B        LODEXIT
*        TEXT     'APLW'  THIS IS THE APLVERSN AT WHICH UNUSED FIXED
SA02     TEXT     'SA02'    DYNAMIC & COMMON WAS ZEROED FOR A SAVED WS.
         PAGE
*
* ACQFID-ACQUIRE FILE ID FOR COMMAND PROCESSING
*
*   SETS  FILENAME,ACCT,PASSWORD, AS INDICATED IN FPT FOR I/O  OPERATION
*   SETS  ACCT AND PASSWORD CONTROL WORDS(OR RESETS) AS INDICATED
*
*   CHECKS FOR END OF COMMAND AS FORMATS INDICATE
*         (NO ADDITIONAL COMMAND SCAN RELEVANT ON EXIT)
*
*   R13=LINK   USES:ACQNXNB FOR CHARACTER ACQUISITION
*                  :ACQIT FOR NAME-NUMBER ACQUISITION
*   EXITS TO ERBADCMD ON BAD FORMAT
*
*  ON EXIT,R1,R2, AND R3 ARE RELEVANT TO THE 1ST NON-BLANK AFTER FID
*
ACQFID   BAL,R14  NAMENUM           CHECK IF NEXT ITEM IS NAME OR NUMBER
         B        SEMICK              NEITHER-NO FID
         B        AFP                NUMBER- ACCT NAME:PASS FORMAT
         BAL,R14  SETFNAME           NAME-SET FILENAME
         CI,R2    X'4B'             .
         BE       ONEDOT             NAME. FORMAT
         CI,R2    X'7A'             :
         BE       PASSNOAC           NAME:PASS FORMAT
         BAL,R14  RESPASS            YES NAME ONLY
         BAL,R14  RESACCT             RESET PASSWORD AND ACCOUNT
         B        CRCHECK
ONEDOT   BAL,R4   ACQNXNB
         CI,R2    X'4B'             .
         BE       PASSNOAC           NAME..PASS FORMAT
         BAL,R14  ACCTCHK           GET THE ACCOUNT                     17-00004
NUMACCT  BAL,R14  SETACCT           SET ACCOUNT
         CI,R2    X'4B'             . CHECK FOR PASSWORD
         BE       PASSWORD             YES
         BAL,R14  RESPASS           RESET PASSWORD
CRCHECK  CI,R2    X'15'             CHECK END
         BE      *R13                YES
         CI,R13   COPYFID+1         CHECK IF ACQFID FOR COPY OR PCOPY
         BE      *R13                YES-MORE TEXT MAY FOLLOW
         CI,R13   SAVETACT            CHECK IF ACQFID FOR SAVE
         BE       SAVETACT             YES-MAY BE FOR AUTOLOAD
         B        ERBADCMD           NO-GARBAGE ERROR
PASSNOAC BAL,R14  RESACCT
PASSWORD BAL,R4   ACQNXNB
         BAL,R14  ACCTCHK           GET THE PASSWORD-USE ACCTCHK        17-00006
         BAL,R14  SETPASS           SET PASSWORD
         B        CRCHECK
AFP      BAL,R14  SETACCT           SET ACCOUNT NUMBER
         BAL,R14  NAMENUM           GET FILE NAME
         B        ERBADCMD           GARBAGE
         B        ERBADCMD           NUMBER-NOT VALID
         BAL,R14  SETFNAME          SET FILE NAME
         CI,R2    X'7A'             :
         BNE      CRCHECK
         B        PASSWORD
SEMICK   CI,R2    X'5E'              ;
         BNE      ERBADCMD
         CI,R13   SAVETACT           CHECK IF SAVE COMMAND
         BNE      ERBADCMD            NO-ERROR
         BAL,R14  RESACCT              YES-RESET ACCOUNT
         BAL,R14  FNEQWSID              AND USE WSID FOR SAVE
         B        SAVETACT
*
* NAMENUM-USED BY ACQFID-CHECKS IF NEXT ACQIT ITEM
*         IS :GARBAGE            EXIT TO CALL+1
*            :NUMBER(INTEGER)            CALL+2
*            :NAME                       CALL+3
*
*        USES ACQIT
*   R14=LINK
*   R12 AND REGISTERS RELEVANT TO ACQIT USED
*
NAMENUM  CLM,R3   NONAME            CHECK NAMECHAR-DIGIT
         BCR,9   *R14                NO
         AI,R14   2                  YES
         CLM,R2   F0F9               CHECK DIGIT
         BCS,9    ACQIT              NO-GET AND USE NAME
         AI,R14   -1                 YES-MESS!
         LW,R12   R14                SAVE RETURN
         BAL,R14  ACQIT              GET MESS
         AI,R5    -1                  CHECK IF ALL DIGITS
GETNCHR  LB,R8    NAMEBUF,R5
         CLM,R8   F0F9
         BCS,9    ERBADCMD          NON-DIGIT-ERROR
         BDR,R5   GETNCHR
         B       *R12               OK
*                                                                       17-00008
* ACCTCHK-GETS ACCOUNT-TERMINATES ON FOLLOWING CHARACTERS:              17-00009
*            COMMA,PERIOD,BLANK,CARRIAGE RETURN                         17-00010
* USES ONLY FIRST 8 CHARACTERS-PRESETS 8 CHARACTERS TO BLANKS           17-00011
*  R14=LINK. R1 TO R5 AND R8 USED.                                      17-00012
*  ROUTINE ACQNXCC USED                                                 17-00013
*                                                                       17-00014
ACCTCHK  AI,R1    -1                 BACK UP MOMENTARILY                17-00015
         LW,R5    BLANKS                                                17-00016
         STD,R5   NAMEBUF            PRESET 8 BLANKS                    17-00017
         LI,R5    -1                                                    17-00018
         LI,R8    9                  INITIALIZE LOOP                    17-00019
ACCTCHK1 AI,R5    1                                                     17-00020
         BAL,R4   ACQNXCC            GET NEXT CHARACTER                 17-00021
         CI,R2    X'40'              BLANK                              17-00022
         BE       ACCTCHK2           YES-SKIP BLANKS AND EXIT
         CI,R2    X'6B'              COMMA                              17-00024
         BE      *R14                 YES-EXIT                          17-00025
         CI,R2    X'4B'              PERIOD                             17-00026
         BE      *R14                 YES-EXIT                          17-00027
         CI,R2    X'15'              CARRIAGE RETURN                    17-00028
         BE      *R14                 YES-EXIT                          17-00029
         CI,R2    X'5E'              SEMI-COLON
         BE      *R14                 YES-EXIT
         STB,R2   NAMEBUF,R5         SET BYTE                           17-00030
         BDR,R8   ACCTCHK1            LOOP-SET UP TO 8 BYTES            17-00031
         B        ACQNXCC               OVERRUN LOOP                    17-00032
ACCTCHK2 LW,R4    R14               SET RETURN
         B        ACQNXNB            GET NON-BLANK
         PAGE
*
* @WSID-DISPLAY OLD WSID, SET NEW NAME(RESET ACCT-PASS)IF INDICATED
*
@WSID    STW,R2   SAVE312           SAVE CR-NOCR FLAG
         CI,R2    X'15'              CHECK IF NEW NAME GIVEN
         BNE      WSIDNEW             YES-OR ERROR.
         LW,R7    ISMSG               NO, GET 'IS  '.
         B        WSIDMSG
WSIDNEW  BAL,R13  ACQFID            ACQ FID.
         BAL,R14  TESTACCT          ERROR IF ACCT SPECIFIED.
         LD,R8    OPWSACT
         STD,R8   LODACCT
         LW,R7    WASMSG            GET 'WAS '.
WSIDMSG  LD,R8    LODACCT           CHECK LOAD ACCT.
         CW,R8    USERACCT           VS USERS ACCT
         BNE      GOWSID              DIFFER
         CW,R9    USERACCT+1
         BNE      GOWSID              DIFFER
         LW,R8    BLANKS              SAME-BLANK FIELD
         LW,R9    BLANKS
GOWSID   LCI      3
         LM,R10   WSIDNAME          GET OLD WSID NAME (TEXTC)
         LCI      6
         STM,R7   IMAGE
         LI,R8    X'40'
         STB,R8   IMAGE+3           BLANK THE C-COUNT
         LI,R3    24
         BAL,R12  DUMPLING          ISSUE MESSAGE
         LW,R2    SAVE312           CHECK IF NEW TO BE SET
         CI,R2    X'15'
         BE       CMDEXIT            NO-EXIT
         LCI      3                  YES
         LM,R8    OPWSNAME
         STM,R8   WSIDNAME           SET NEW NAME
         LD,R8    OPWSPAS           SET (OR RESET)                      U17-0005
         STD,R8   WSIDPASS           NEW PASSWORD                       U17-0006
         LW,R8    USERACCT
         LW,R9    USERACCT+1
         STD,R8   LODACCT            RESET LODACCT TO USERS ACCT
         B        CMDEXIT             EXIT
         PAGE
*
* @DROP-RELEASE AN INDICATED WS OR FILE FROM THE USERS ACCOUNT
*
@DROP    BAL,R13  ACQFID            GET FID
         BAL,R14  TESTACCT           QUIT IF ACCT(NOT USERS)SPECIFIED
         BAL,R14  DROPFILE            DROP FILE
         B        CMDEXIT
         PAGE
*
* @COPY AND @PCOPY-DRIVER FOR COPY AND PROTECTED COPY FROM WORKSPACE
*
@COPY    LI,R13   0
         STW,R13  PCOPYFLG          SET PCOPYFLG = 0 (I.E. NOT).
         B        SETQUIET
@PCOPY   STW,R6   PCOPYFLG          SET PCOPYFLG = SMALL NEG.INTEGER.
SETQUIET SW,R6    CMNDTYPE          SET QUIET-FLAG: -1 -- IF QUIET &
         STW,R6   QUIETFLG                           0 -- IF NOISY.
COPYFID  BAL,R13  ACQFID            GET FILE ID FOR WS TO COPY
         BAL,R4   ACQNB                 ACQUIRE NON-BLANK CHARACTER     17-00034
         STW,R1   IMAGEPOS               SAVE POINTER TO CHARACTER      17-00035
         AI,R4    2                     SET RETURN FROM ACQNXNB(BELOW)  17-00036
         CLM,R3   NONAME            VERIFY NAME-LIST HAS NAME-CHARS ONLY
         BCS,9    ACQNXNB             OK, LOOP PAST ANY BLANKS.
         AI,R2    -NEWLINE            NO, VERIFY END-OF-STMT...
         BNEZ     ERBADCMD              OOPS -- INCORR. CMND.
         LW,R14   MODE              ARE WE IN FUN DEFN MODE...
         BNEZ     A5                  NO.
         BAL,R14  B4CLOSE             YES, DO FORCED CLOSE.
A5       BAL,R14  TRYLOAD           FIND COPY WS, PUT HDR IN IDBUF:
*
*    IDBUF -- WORDS OF INTEREST WHEN COPYING:
*
*    IDBUF + 0    SYMTOFF  = OFFSET OF COPY SYM TBL IN COPY DYNAMIC.
*    IDBUF + 1    SYMTSIZE = SIZE (# OF ENTRIES) OF COPY SYM TBL.
*    IDBUF + 2    FREETBL  = LOC OF 1ST WD BEYOND COPY DYNAMIC.
*    IDBUF +4     LODYN    = LOC OF 1ST WD OF COPY DYNAMIC.
*    IDBUF + 8 THRU + 11   = TIME & DATE WHEN COPY WS WAS SAVED.
*
         LW,R13   IDBUF+2
         SW,R13   IDBUF+4           CALC. SIZE OF COPY DYNAMIC.
         STW,R13  COPYSIZE
         LW,R13   HICOMMON
         SW,R13   LODYN             CALC. SIZE OF USER'S ALLOCATION AND
         AI,R13   -STACKOFF-4         VERIFY COPY DYNAMIC CAN AT LEAST
         SW,R13   COPYSIZE            BE LOADED...
         BGEZ     COPY                  OK.
         LI,R8    ID2BIGLD              BARF -- TOO BIG TO LAAD.
         LI,R6    CMDERR            CLOSE COPY WS FILE, REPORT ERROR,
         B        CLOSV               AND EXIT FROM COMMAND.
         PAGE
*
*  @LIB-DRIVER TO LIST WORKSPACES IN INDICATED ACCOUNT
*
*
*  WORK IS DONE IN 'APLUTSI'-APL UTS INTERFACE MODULE
*
@LIB     RES      0
         B        LIBUTS
         PAGE
*
* @SYMBOLS-SET SYMBOL TABLE SIZE-(IF THIS IS CLEAR WS)
*
@SYMBOLS BAL,R14  BAQCONLY          GET CONSTANT, STORE IN CONSTBUF.
         BL       SYMBOLD            NO NEW VALUE
         BG       ERBADCMD          MORE THAN 1 VALUE
         CI,R7    2001                  RANGE TEST
         BG       ERBADCMD               TOO HIGH
         LI,R8    21                OK-COMPUTE 20I+41
ADD20    AI,R8    20
         CW,R8    CONSTBUF
         BL       ADD20
         BAL,R14  QCLEAR             CHECK IF CLEAR  WS
         BNE      ERBADCMD            NO
         SLS,R8   1
         STW,R8   NSYMTWDS          NO. OF WORDS IN SYMTABLE
         SLS,R8   -1
         XW,R8    SYMTSIZE          SYMBOL TABLE SIZE,OLD VALUE NOW IN 7
         STW,R8   CONSTBUF          SAVE OLD VALUE
         LW,R8    SYMT
         AW,R8    NSYMTWDS          END OF SYMBOL TABLE
         STW,R8   NEWBOUND
         BAL,R14  GETDYN            GET MEMORY IF REQUIRED
         LW,R1    SYMTSIZE           GET SYMT SIZE
         B        SETSYMT             USE 'CLEAR' TO FINISH
OLDSYMS  LW,R7    CONSTBUF          GET OLD VALUE
         B        OUTORANG+1         ISSUE MESSAGE AND EXIT
SYMUSAGE TEXTC    ' UNUSED OF '
SYMBOLD  BAL,R14  UNSYMS            GET NO.OF UNUSED SYMBOLS.
         LW,R8    R11               PUT THAT NO. IN R8.
         LI,R3    0                 INIT. POSITION IN IMAGE.
         BAL,R13  CINTIM            CV NO. TO EBCDIC & PUT IN IMAGE.
         LI,R8    SYMUSAGE          PT AT TEXTC MSG.
         BAL,R13  TEXTC2I           MOVE IT TO IMAGE.
         LW,R8    SYMTSIZE          GET SIZE OF SYM TBL.
         B        VALOUT            APPEND THAT VALUE, DISPLAY, EXIT.
*
* UNSYMS -- GETS NO.OF UNUSED SYMBOLS IN R11.
*
*  R14 = LINK.  R3,R8,R13 ARE VOLATILE.
*
UNSYMS   LI,R11   0                 CLEAR UNUSED SYMBOL COUNT.
         LW,R13   SYMTSIZE          NO.OF ENTRIES FOR SYM TBL.
         LW,R3    SYMT
UNSYMSQ  LW,R8    1,R3              LOOK AT NAME-INDICATOR WORD...
         BNEZ     UNSYMSN             NAME IN USE.
         AI,R11   1                   UNUSED.
UNSYMSN  AI,R3    2                 PT AT NEXT SYM TBL ENTRY.
         BDR,R13  UNSYMSQ           LOOP TILL DONE.
         B       *R14               EXIT
*
* QCLEAR-CHECK IF CLEAR WS
*
*  R14=LINK, R13 USED
*
*  EXIT  WITH  CC'S SET FOR = IF CLEAR, NOT= OTHERWISE
*
QCLEAR   LW,R13   DYNBOUND          HIGHEST AVAIL DYNA
         SW,R13   SYMT
         SW,R13   NSYMTWDS          TOTAL AVAIL DYNAMIC
         CW,R13   FREETBL+1
         B       *R14
         PAGE
*
* @OPR-GENERATE OPERATOR MESSAGE-WAIT FOR REPLY
* @OPRN-NO WAIT FOR REPLY
*
*
@OPRN    LI,R6    0
@OPR     STW,R6   PCOPYFLG          SAVE WAIT/NO-WAIT FLAG
         LW,R6    HICOL
         AI,R6    -BA(IMAGE)        MESSAGE LENGTH-1
         STB,R6   IMAGE             CONVERT TO TEXTC WITH LENGTH L-1
         BAL,R14  GENOPRM           GENERATE OPERATOR MESSAGE
         LI,R8    SENTMSG
         BAL,R7   WRTEXTC           GENERATE 'SENT' MESSAGE
         LW,R7    PCOPYFLG          CHECK IF 'WAIT'
         BEZ      CMDEXIT            NO
OPRWAIT  BAL,R14  DELAY6             YES-
         MTW,0    BREAKFLG            DELAY UNTIL BREAK
         BEZ      OPRWAIT
         B        CMDEXIT
SENTMSG  TEXTC    'SENT'
         PAGE
*
* @TERM-TERMINAL COMMAND-READ A NEW SET OF TRANSLATION TABLES
*
@TERM    BAL,R14  BAQCONLY          GET N
         BG       ERBADCMD           TOO MANY
         BE       NEWTERM            1
         LW,R7    TERMTYPE           NONE
         B        GENIS             GENERATE THE 'IS  ' VERSION.
NEWTERM  CW,R7    TERMTYPE           CHECK NEW VS OLD
         BE       OUTORANG+1          SAME-MESSAGE ONLY
         B        GETTERM              DIFFER
         PAGE
*
* @TABS-CHANGE TAB SETTING(S) AND(OR) REPORT OLD VALUE(S)
*
@TABS    BAL,R14  BAQCONLY          GET CONSTANT(S)
         BL       TABSOLD           NONE.
         LI,R4    CONSTBUF          ADDRESS OF TABS
         BAL,R5   QTABVLID          CHECK VALIDITY OF NEW TABS
         B        ERBADCMD           BAD
         LW,R3    WASMSG            OK, GENERATE THE 'WAS ' MSG.
TABSMSG  STW,R3   IMAGE
         LI,R3    4
         LI,R6    1                 SET INDEX
         LI,R10   1                  AND COUNT
         LW,R8    TABPNTR             CHECK TYPE OF TABS
         CI,R8    128
         BL       TABEVEN           EVEN-ONE VALUE
         LB,R10   TABVALS           ODD- N VALUES
TABODD   LB,R8    TABVALS,R6
         AI,R6    1
TABEVEN  BAL,R13  CINTIM            GENERATE VALUE
         BAL,R11  STASHBL            BLANK
         BDR,R10  TABODD              LOOP
         BAL,R12  DUMPLING          DUMP LINE
         LI,R4    CONSTBUF
         BAL,R5   SNEWTABS          SET NEW TABS
         B        CMDEXIT            EXIT
TABSOLD  LW,R3    ISMSG             GENERATE THE 'IS  ' MSG.
         B        TABSMSG
         PAGE
*
* CONTINUE;CONTINUE HOLD;AUTOMATIC CONTINUE
*
@CONTINU RES      0
         AI,R2    -NEWLINE          CHECK  CR
         BEZ      CONTOFF            YES
         BAL,R14  ACQIT               NO
         LW,R8    HOLD                 CHECK 'HOLD'
         CW,R8    NAMEBUF
         BNE      ERBADCMD              NO-ERROR
CONTOFF  STW,R2   HOLDFLG           SAVE HOLD-OFF FLAG
         LI,R8    @@CONT-CMDB-NCMDS   'CONTINUE' COMMAND TYPE
         STW,R8   CMNDTYPE            (SET FOR 'HANG-UP' CASE)
         MTW,0    ON%OFF            CHECK IF OFF-LINE
         BGZ      CONT1               NO
         MTW,-1   QUITFLAG            YES-AVOID REPEATED ATTEMPTS
         BLZ      UTSIOFFH             TO SAVE 'CONTINUE'
CONT1    LCI      3
         LM,R6    KONTINUE          SET WSID TO 'CONTINUE'
         STM,R6   WSIDNAME
         B        NOFID             ENTER 'SAVE' LOGIC
 PAGE
************************************************************************
 SPACE 2
Z        SET      %-CMD@            SIZE OF CMD MODULE IN HEX.
 SPACE
Z        SET      Z+Z/10*6+Z/100*96+Z/1000*1536  SIZE IN DECIMAL.
 SPACE 3
         END

