      HED UNPROTECT 
* UNPROTECT IS IDENTICAL TO PROTECT EXCEPT THAT IT CLEARS THE 
* PROTECT BIT INSTEAD OF SETTING IT.
      ORG LIBRA 
      LDA MLINK+1 
      ORG PRO7
      ELA,CLE,ERA 
      HED OPEN
* THE OPEN COMMAND IS A USER FUNCTION WHICH CAUSES THE SYSTEM TO
* CREATE ROOM FOR A DATA FILE. THE FORMAT FOR THE COMMAND IS: 
* qq
*     OPEN-FILENAME,LENGTH
* 
* THE FILENAME IS SUBJECT TO ALL THE RULES OF PROGRAM NAMES. THE
* LENGTH IS A DECIMAL INTEGER FROM 1 TO 128 INDICATING THE FILE 
* LENGTH IN SECTORS.
      SPC 2 
      ORG LIBRA 
      LDA MLINK+1   GET ID AND STORE
      ADA .+?ID-?LINK    IN LTEMP.
      LDA 0,I 
      STA ID
      STA LTEMP 
      LDA DLTEM     SET UP POINTER FOR
      STA OPEP       NAME.
      LDA .-3       SET UP COUNTER. 
      STA OPEC
      CLA           SET FLAG SAYING FIRST 
      STA OPEF       CHAR.
OPE1  JSB OPER      GET A CHARACTER.
      ALF,ALF       STORE IN
      ISZ OPEP       NAME AREA. 
      STA OPEP,I
      JSB OPER      GET RIGHT CHAR. 
      IOR OPEP,I    MERGE IN. 
      STA OPEP,I
      ISZ OPEC      TEST FOR ANY MORE.
      JMP OPE1
* 
      JSB OPER      NEXT CHARACTER MUST BE
      CPA .+40B      BLANK. 
      JMP OPE2
      JMP ILFER     OUTPUT ILLEGAL FORMAT MESSAGE.
* 
OPER  NOP           GET NEXT CHAR FOR NAME. 
      LDA OPEF      TEST TO SEND BACK BLANK.
      CPA .+40B 
      JMP OPER,I
OPER1 JSB LCHAR     GET NEXT CHAR.
      JMP ILFER     FAIL IF NONE. 
      LDB 0         SAVE IN B.
      AND .140      SKIP CONTROL CHARS. 
      SZA 
      CPA .140
      JMP OPER1 
      LDA OPEF      GET 1ST CHAR. FLAG. 
      SZA           TEST FOR 1ST CHAR.
      JMP OPER2     NOT.
      CPB .+54B     TEST FOR COMMA OR $ 
      JMP ILFER 
      CPB .+44B 
      JMP ILFER 
OPER3 LDA 1         RETURN CHAR IN B
      ISZ OPEF
      JMP OPER,I
OPER2 CPB .+54B     COMMA TEST
      RSS 
      JMP OPER3 
      LDA .+40B 
      STA OPEF
      JMP OPER,I
* 
* GET FILE LENGTH.
* 
OPE2  CLA           INITIALIZE # TO 0 
      STA OPEF
      JSB LCHAR     GET A CHAR. 
      JMP OPE3      DONE
      ADA M72B      DIGIT TEST. 
      SSA,RSS 
      JMP ILFER 
      ADA .+10
      SSA 
      JMP ILFER 
      STA OPEC      SAVE DIGIT. 
      LDA OPEF
      MPY .+10      BUILD NEW 
      CLE            NUMBER.
      ADA OPEC
      SEZ,SZB,RSS   OVERFLOW CHECK. 
      JMP OPE2+1
      JMP ILFER 
* 
OPE3  LDA OPEF      TEST FOR LEGAL VALUE. 
      CMA,CLE,INA,SZA,RSS 
      JMP ILFER 
      ADA .+48     TOO BIG? 
      SEZ,RSS 
      JMP ILFER 
* 
      LDA OPEF
      CMA,INA 
      ASL 7        CONVERT TO WORDS              X] 
      STA OPEFN 
      JSB FIDT    READ ID TRACK 
      ADB .+6       TEST FOR USER OUT OF CORE.
      LDA 1,I 
      CMA,CLE 
      INB 
      ADA 1,I 
      ADA OPEF
      SEZ,RSS 
      JMP OPE4
* qq
      LDB *+3 
      LDA .-16
      JMP LIBER 
      DEF *+1 
      OCT 5106
      ASC 7,ILE SPACE FULL
* 
* SEARCH ADT FOR SPACE TO PUT THE FILE. 
* *q
OPE4  LDA OPEF     MAKE THE REQUIRED DISC SPACE 
      CMA,INA      NEGATIVE FOR FDISC 
      STA OPEF     SAVE NEGATIVE LENGTH 
      JSB FDISC    SEARCH FOR DISC SPACE
      LDB LTEMP+8  LOAD ADT POINTER 
      STB OPEC                                   X] 
* 
      LDA LTEMP+2   SET T*
      IOR BIT15     FILES 
      STA LTEMP+2   BIT 
      JSB DLOOK     SEARCH FOR ENTRY. 
      JMP OPE8      ENTRY FOUND--ILLEGAL. 
OPE11 EQU * 
      JSB FDIRC    COMPUTE DIRECTORY
      LDA LTEMP      SET UP TO LOOK                  [X]
      IOR BIT15                                      [X]
      STA LTEMP         FOR ONLY 1 TRACK             [X]
      LDA LTEMP+4,I 
      SZA,RSS      IF TRACK IS EMPY THEN TRY
      JMP OPE53    FIRST TRACK
* qq
      LDA DLTEM                                  X] 
      LDB LTEMP+4                                X] 
      INB                                        X] 
      JSB DIRCM                                   X]
      JMP OPE53                                   X]
OPE54 JSB DLOOK                                   X]
      NOP 
* *q
      LDB LTEMP+4,I IF DIRECTORY TRACK IS 
      CPB O4560     FULL, DO                      (D) 
      JMP OPE98       OVERLAY.
* qq
      CMB           SET UP SOURCE 
      ADB LIBD       FOR MOVE.
      STB MOVES 
      ADB .+8       SET UP DESTINATION. 
      STB MOVED 
      CMB           COMPUTE LENGTH. 
      ADB .+16
      ADB LTEMP+5 
      JSB MOVEB 
* 
      LDA LTEMP       CLEAR BIT 15 OF ID             [X]
      ELA,CLE,ERA                                    [X]
      STA LTEMP                                      [X]
      LDA DLTEM     MOVE 4 WORDS IN FOR 
      STA MOVES      NEW ENTRY. 
      LDA LTEMP+5 
      ADA .+8 
      STA MOVED 
      LDB .-4 
      JSB MOVEW 
      JSB DATE      STORE DATE IN ALSO. 
      ISZ MOVED 
      STA MOVED,I 
      ISZ MOVED 
      LDB OPEFN Nx
      LDA OPEDS 
      DST MOVED,I 
* 
      LDA LTEMP+4,I ADJUST DIRECTORY
      ADA .-8        LENGTH.
      STA LTEMP+4,I 
      STA WORD
      LDA LTEMP+4   WRITE DIRECTORY 
      INA            BACK OUT.
      STA MOVED 
      ADA .+5 
      LDA 0,I 
      LDB LIBD
      STB MOVES 
      JSB DISCL 
* 
      LDB .-4       RESET 
      JSB MOVEW      DIREC. 
* 
      LDB OPLOV 
      STB WORD
      LDB LIB       LOAD
      INB             OVERLAY 
      LDA 1,I 
      LDB #LIBI 
      JMP OPOVL 
* qq
OPE53 LDB LTEMP+4                                X] 
      ADB .-7                                    X] 
      STB LTEMP+4                                X] 
      INB                                        X] 
      LDA DLTEM                                  X] 
      JSB DIRCM                                  X] 
      JMP OPE55                                  X] 
      JMP OPE54                                  X] 
      JMP OPE54                                  X] 
OPE55 LDA LIBD                                   X] 
      ADA .-8                                    X] 
      STA LTEMP+5                                X] 
      LDB LTEMP+4                                X] 
      LDA 1,I    MAKE SURE THE CORRECT DIREC         [X]
      STA WORD       TRACK IS IN CORE                [X]
      ADB .+6         BEFORE WE CONTINUE             [X]
      LDA 1,I                                        [X]
      LDB LIBDI                                      [X]
      JSB DISCL                                      [X]
      JMP OPE54+2                                X] 
* 
OPE98 LDA M250
      STA WORD
      LDA OPEOV,I 
      LDB #LIBI 
      JMP LIBRA+252 
* 
OPEDS EQU LTEMP+6 
OPEFN EQU LTEMP+7 
OPEF  EQU LTEMP+13
OPEDF EQU LTEMP+12
OPEC  EQU LTEMP+9 
OPEP EQU LTEMP+10 
OPE8  LDA .-16
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5104
      ASC 7,UPLICATE ENTRY
* qq
OPEOV DEF SAVO+COM6-COM3
OPLOV ABS LIBRA-$$OPE 
M250  DEC -250
O4560 DEC -4560                                   (D) 
* qq
      ORG LIBRA+250 
OPOVL JSB DISCL     LOAD
      JMP LIBRA       OVERLAY 
      ORG LIBRA+252 
      JSB DISCL 
      JMP LIBRA 
      JMP OPE11     NORMAL RETURN.
      JMP FD.1+7      SYSTEM OVERLOAD                  [X]
$OPE  EQU * 
      HED  OPEN OVERLAY 
      ORG LIBRA 
* 
      JSB FIDT
      ADB .+7 
      LDA OPEF      ADJUST AMOUNT OF DISC USED. 
      CMA,INA      MAKE OPEF POSITIVE 
      STA OPEF
      ADA 1,I 
      STA 1,I 
* 
      LDA IDTRA,I    DUMP 
      LDB LIBD        IDT 
      JSB DISCL          BACK 
      LDA ADLEN             TO DISC 
      STA WORD      LOAD ADT FROM 
      LDA ADLOC       DISC
      LDB LIBDI 
      JSB DISCL 
      LDB OPEDF     GET -# OF SECTORS LEFT IN ADT.
      LDA OPEF      GET # OF SECTORS USED.
      SZB        TEST FOR ANY PART LEFT                [X]
      JMP OPE9      NON EMPTY ADT ENTRY.
* qq
      LDB OPEC      SQUEEZE OUT ADT ENTRY.
      STB MOVED 
      ADB .+2 
      STB MOVES 
      ADB MLIBD D=
      ADB WORD
      JSB MOVEW 
* 
      ISZ ADLEN     REDUCE ADLEN BY 2.
      ISZ ADLEN 
      ISZ WORD      REDUCE TRANSFER LENGTH
      ISZ WORD       BY 2.
      JMP OPE10 
* 
OPE9  ADA OPEC,I    MODIFY ADT ENTRY. 
      DST OPEC,I
* 
OPE10 LDA ADLOC     WRITE ADT BACK TO DISC
      LDB LIBD
      JSB DISCL 
* 
      LDB .-24     WRITE -1 (EOF) IN EACH OF 24  X] 
      STB OPEC      SECTORS.
      LDB LIBD
      CCA 
      STA 1,I 
      ADB B200                                   X] 
      ISZ OPEC
      JMP *-3 
* 
      LDA OPEDS     A=FILE ADDRESS. 
      LDB OPEF    GET # OF SECTORS. 
      ADB .-25      IS FILE LONGER
      SSB             THAN 24?
      JMP OPO1      NO
      CMB           YES - FIRST TAKE CARE OF EXTRA
      BLF,BLF       WRITE EOFS
      RBR             TO DISC 
      STB WORD
      LDB LIBD
      JSB DISCL 
      LDA OPEDS     COMPUTE NEW 
      ADA OPEF        DISC ADDRESS
      ADA .-24
      LDB .+24
      RSS              OF THE REST
* 
OPO1  LDB OPEF      WRITE EOFS
      CMB,INB 
      BLF,BLF 
      RBR 
      STB WORD
      LDB LIBD
      JSB DISC,I
      CLF 0 
      ISZ LIB       OPEN NOT IN CORE
      STF 0 
      JMP LLEND     TERMINATE 
* 
$$OPE EQU * 
      HED LENGTH
* THE LENGTH COMMAND CAUSES THE LENGTH OF THE USER'S PROGRAM TO 
* BE PRINTED ON THE USER'S CONSOLE. 
      SPC 1 
      ORG LIBRA 
      JSB RDPRG     READ IN USER PROGRAM. 
      LDB MLINK+1 
      ADB .+?PROG-?LINK 
      LDA 1,I       GET POINTER TO END OF 
      STA LTEMP      PROGRAM. 
      CPA PBUFF     IF NULL PROGRAM GO TO PRINTOUT
      JMP LEN1       SECTION. 
      ADB .-?PROG+?MASK              [X]
      LDA CFLAG      TEST FOR COMPILED [X]
      AND 1,I                          [X]
      ADB .-?MASK                      [X]
      SZA,RSS 
      JMP LEN1      USER NOT COMPILED.
      LDA SYMTB     USE SOURCE PROGRAM POINTER
      RSS 
LEN1  LDA LTEMP 
      CMA           COMPUTE LENGTH IN WORDS.
      ADA SPROG 
      CMA 
      SSA           IF NEGATIVE,
      CLA             SET TO ZERO 
      STA LTEMP 
* *q
      LDA .+12B     OUTPUT LINE FEED. 
      JSB LOUT>>
      LDA .-2       SET COUNTER.
      STA LTEMP+1 
      LDA LTEMP     GET FIRST 2 DIGITS IN A.
      CLB            LAST 2 IN B. 
      DIV .100
      STB LTEMP 
LEN2  CLB 
      DIV .+10      GET 2 DIGITS. 
      STB LTEMP+2   SAVE 2ND. 
      ADA .+60B B|
      JSB LOUT      PRINT 1ST 
      LDA LTEMP+2 
      ADA .+60B     PRINT 
      JSB LOUT       2ND. 
      LDA LTEMP     GET 2ND PAIR. 
      ISZ LTEMP+1   TEST FOR DONE.
      JMP LEN2N
      LDA .-6       PRINT " WORDS". 
      LDB *+2 
      JMP LIBER 
      DEF *+1 1;
      ASC 3, WORDS
$LEN  EQU * 
      HED  ECHO COMMAND 
* *q
*     ECHO-OFF SETS THE TERMINAL TO HALF DUPLEX 
*     MODE.   
*     ECHO-ON RETURNS THE TERMINL TO FULL DUPLEX
* 
      SPC 2 
      ORG LIBRA 
      JSB LCHAR     GET CHARACTER 
      JMP ILFER     ILLEGAL FORMAT
      ALF,ALF       ROTATE IT UP
      STA ECHR      SAVE IT 
      JSB LCHAR     GET NEXT CHAR 
      JMP ILFER 
      IOR ECHR      ADD ON PREVIOUS CHAR
      LDB MLINK+1 1
      ADB .+?RPRM-?LINK 
      CPA ECON      ECHO-ON?
      JMP ECHO1     YES 
      CPA ECOF      ECHO-OFF? 
      JMP ECHO2     YES 
      JMP ILFER     ILLEGAL FORMAT
* 
ECHO1 LDA 1,I       LOAD RECEIVE PARAM. 
      IOR ECOBT     ADD ON ECHO BIT 
      STA 1,I       RESTORE RECEIVE PARAM 
      JMP ECHO3     OUTPUT IT 
* qq
ECHO2 LDA NECHO     REMOVE ECHO BIT 
      AND 1,I         FROM RPRM 
      STA 1,I 
* 
*     OUTPUT RECEIVE PARAMETER
* qq
ECHO3 ADB .+?TNUM-?RPRM 
      LDB B,I       LOAD TELETYPE NUMBER
      JSB MUXR,I    OUTPUT RECEIVE PARAMETER
      JMP LLEND     TERMINATE 
* 
ECOBT EQU BIT12 
ECHR  EQU LTEMP 
ECON  ASC 1,ON
ECOF  ASC 1,OF
$ECH  EQU * 
      HED REPORT
* THE REPORT COMMAND CAUSES IDT INFO TO BE LISTED ON THE SYSTEM 
* TELETYPE. EACH USER ID IS LISTED, ALONG WITH THE DISC AND TIME
* USED TO DATE. DISC STORAGE IS LISTED IN WORDS, AND TIME IS LISTED 
* IN MINUTES. 
      SPC 2 
      ORG LIBRA 
      LDA IDTTA    SET ID TRACK POINTER 
      ADA .+3 
      STA REPTA 
      LDA IDTRL 
      ADA .+3 
      STA REPTL       POINTER 
* 
      LDA LIBD      SET WORD POINTER
      STA REPID 
      LDA T35B1      TO PRINT 
      STA MOVED       BUFFER. 
      LDA REPHD D>
      STA MOVES Sx
      LDB REP29 
      JSB MOVEW 
      LDB IDLEN     USE WORD 35 OF THE BUFFER TO
      BRS,BRS 
      BRS S8
      STB REPLN      COUNT ID ENTRIES.
      LDA REP57     WE WILL PRINT 57 CHARACTERS.
      SZB           IF ID TABLE IS LENGTH >0, GO TO 
      JMP REP1       PRINT AND SUSPEND. 
REP2  LDB T35B1     OTHERWISE, JUST PRINT THE 
      JMP LEND2     HEADING AND TERMINATE.
* 
REP1  LDB T35B1     PRINT AND 
      JSB T35SP      SUSPEND. 
      LDA .-3       SET COUNTER 
      STA REPCT       FOR THREE ENTRIES 
      LDA T35B1 
      STA REPBF 
* 
REP8  LDA REPTL,I    READ ID TRACK
      STA WORD
      LDA REPTA,I 
      LDB LIBDI I1
      JSB DISCL 
      LDA REPTL,I      COMPUTE
      CMA,INA            END
      ADA LIBD            POINTER 
      STA REPND 
* *q
* 
* qq
* NOW CONVERT ENTRIES INTO THE BUFFER. REPID POINTS AT THE ENTRY, 
* REPBF POINTS TO THE OUTPUT BUFFER.
* *q
REP4  LDA REPID,I   GET ID. 
      AND B1777     MASK NUMBER PART. 
      CLB           GET #/100 IN A, # MOD 100 IN B. 
      DIV .100
      STB REPT      SAVE LAST 2 DIGITS. 
      STA 1         COMBINE FIRST DIGIT WITH
      LDA REPID,I    LETTER.
      ARS,ARS 
      AND REPMS 
      ADA 1 
      ADA REPFX 
      STA REPBF,I   STORE ASCII LETTER&DIGIT IN BUF.
      ISZ REPBF 
      LDA REPT      CONVERT LAST 2 DIGITS 
      JSB REPNM      AND STORE IN BUFFER. 
      STA REPBF,I 
      ISZ REPBF     MOVE REPBF TO POINT AT TIME AREA
      LDA REPID     SET REPID TO POINT
      ADA .+5        TO USERS TIME. 
      STA REPID 
      LDA REPID,I   GET USERS TIME. 
      JSB REPTR     CONVERT INTO BUFFER.
      ISZ REPID     POINT TO DISC USED
      ISZ REPID      AND
      LDA REPID,I KK
      JSB REPTR     CONVERT IT. 
      ISZ REPBF     MOVE BUFFER POINTER UP FOR
      ISZ REPBF      NEXT ENTRY.
      ISZ REPID     MOVE ID POINTER ALSO. 
      ISZ REPCT      ALL DONE?
      RSS            NO 
      JMP REP5       YES? 
* 
      ISZ REPLN      ANY MORE ID'S? 
      RSS            YUP
      JMP REP6      NO - TERMINATE
      LDA REPID      END OF ID TRACK? 
      CPA REPND DT
      JMP REP7       YES
      JMP REP4
* 
REP6  LDA REPBF     COMPUTE 
      ADA REPTT       # OF CHARS  
      ALS                  TO OUTPUT
      JMP REP2      TERMINATE 
REP5  ISZ REPLN     ALL DONE? 
      RSS           NO
      JMP REP6         YUP
      LDA REPID      END-OF-TRACK?
      CPA REPND 
      JMP REP7
      LDA REP56 
      JMP REP1       NO 
REP7  LDA REPTA     YES, SET POINTERS 
      ADA .-1            TO NEXT
      STA REPTA         TRACK 
      LDA REPTL 
      ADA .-1 
      STA REPTL 
      LDA LIBDB
      STA REPID --
      LDA REPCT 
      SZA 
      JMP REP8
      LDA REP56 
      JMP REP1
* qq
REPNM NOP           CONVERT A #<100 TO ASCII. 
      CLB           GET 1ST DIGIT IN A. 
      DIV .+10       2ND IN B.
      ALF,ALF       PACK AND
      ADA 1          ADD ON ASCII 
      ADA ASC00       BITS. 
      JMP REPNM,I 
* 
REPTR NOP           TRANSLATE A 5-DIGIT NUMBER
      CLB             INTO THE BUFFER.
      DIV DVSRS     CONVERT FIRST 
      ADA REPB0      DIGIT. 
      STA REPBF,I   PUT IN
      ISZ REPBF      BUFFER.
      LDA 1         NOW GET THE REST. 
      CLB 
      DIV .100      COMPUTE AS 2 2-DIGIT #S.
      STB REPK      SAVE 2ND HALF.
      JSB REPNM     CONVERT AND STORE 
      STA REPBF,I    FIRST PART.
      ISZ REPBF F?
      LDA REPK      SAME WITH 
      JSB REPNM      2ND PART.
      STA REPBF,I 
      ISZ REPBF 
      JMP REPTR,I 
* 
REPHD DEF *+1 SS
      OCT 5040
      ASC 20,ID   TIME DISC      ID   TIME DISC 
      ASC  8,ID   TIME DISC 
REPLN EQU T35BF+35
REPK  EQU LTEMP 
REPCT EQU LTEMP+1 
REPBF EQU T35BF+34
REPID EQU T35BF+333@
REPT  EQU T35BF+32
REPTL EQU T35BF+31
REPTA EQU T35BF+30
REPTT ABS -T35BF-2-l
REPND NOP 
REPMS OCT 17400 
REPFX ASC 1,@0
REPB0 ASC 1, 0
REP29 DEC -29 
REP57 DEC 57
REP56 DEC 56
$REP  EQU * 
