
      HED CHANGEID
* THE CHANGEID COMMAND CAN BE USED TO MODIFY THE PARAMETERS IN AN 
* ID ENTRY. THE MODIFIABLE ENTRIES ARE THE PASSWORD, TIME ALLOWED,
* AND DISC ALLOWED. THE POSSIBLE FORMATS ARE: 
* 
*     CHANGEID-ID,PASSWORD,TIME,DISC
*     CHANGEID-ID,PASSWORD,TIME 
*     CHANGEID-ID,PASSWORD,,DISC
*     CHANGEID-ID,,TIME,DISC
*     CHANGEID-ID,PASSWORD
*     CHANGEID-ID,,TIME 
*     CHANGEID-ID,,,DISC
      SPC 2 
      ORG LIBRA 
      SPC 1 
      JSB GETID     GET ID ENTRY. 
      RSS           SKIP TO COMMA TEST. 
      JMP LFRER     FAIL IF NOTHING FOLLOWS.
      CPA .+54B     TEST FOR COMMA FOLLOWING. 
      RSS           OK. 
      JMP LFRER     FAIL IF NO COMMA FOLLOWS. 
* 
      JSB SIDTP,I 
      SZB 
      JMP CHA3
* 
      LDA CHA2E     OUTPUT 'NO ID' MESSAGE
      STA MOVES 
      LDA T35B1 
      STA MOVED 
      LDB .-6 
      JSB MOVEW 
      LDA .+11
      LDB T35B1 
      JMP LEND2 
CHA2E DEF *+1 
      OCT 5116      LF-N
      ASC 5,O SUCH ID 
* 
* B NOW POINTS TO THE CORRECT ID. 
* 
CHA3  INB           SET CHAID TO POINT TO THE 
      STB CHAID      PASSWORD.
      STB CHAI1     STORE COPY IN CHAI1.
      JSB T35CH,I   GET FIRST CHARACTER OF POSSIBLE 
      JMP LFRER      PASSWORD--ERROR IF NONE. 
      CPA .+54B     IF COMMA, WE DON'T WANT TO
      JMP CHA5       CHANGE PASSWORD. 
      CLB           INITIALIZE PASSWORD 
      ISZ CHAID       TO NULLS. 
      STB CHAID,I 
      ISZ CHAID 
      STB CHAID,I 
      LDB CHAI1     SET CHAID TO POINT AT 
      STB CHAID       PASSWORD AGAIN. 
      LDB .-3       SET COUNTER FOR 3 WORD
      STB CHAC       PASSWORD.
CHA4  ALF,ALF       SET LEFT CHARACTER OF WORD. 
      STA CHAID,I 
      JSB T35CH,I   GET RIGHT CHARACTER.
      JMP CHA10     TERMINATE IF CR.
      CPA .+54B     IF COMMA, WE'RE DONE WITH 
      JMP CHA5       PASSWORD.
      IOR CHAID,I   MERGE IN WITH LEFT CHAR.
      STA CHAID,I 
      ISZ CHAC      TEST FOR ALL OF PASSWORD IN.
      RSS           NOT ALL IN YET. 
      JMP CHA6
      ISZ CHAID     BUMP POINTER. 
      JSB T35CH,I   GET ANOTHER PASSWORD CHARACTER. 
      JMP CHA10     DONE IF CR. 
      CPA .+54B     TEST FOR COMMA. 
      JMP CHA5
      JMP CHA4      LOOP. 
* 
CHA6  JSB T35CH,I   TEST FOR TOO MANY PASSWORD CHARS. 
      JMP CHA10     END OF REQUEST. 
      CPA .+54B     TEST COMMA. 
      RSS 
      JMP LFRER     FAIL. 
* 
CHA5  LDA CHAI1     SET CHAID TO POINT TO 
      ADA .+3       TIME ALLOWED. 
      STA CHAID 
* 
      JSB T35CH,I   GET 1ST CHAR OF POSSIBLE TIME.
      JMP LFRER     ERROR IF NONE.
      CPA .+54B     IF COMMA, GO TO DO DISC PART. 
      RSS 
      JSB CHA#      OTHERWISE GET NEW ALLOTTED TIME.
      ISZ CHAID     SET POINTER TO ALLOTTED DISC
      ISZ CHAID      SPACE. 
      JSB T35CH,I   GET FIRST DIGIT OF DISC.
      JMP LFRER     FAIL IF NONE. 
      JSB CHA#      COMPUTE IT. 
      JMP LFRER     RETURN HERE IS ILLEGAL. 
* 
CHA10 EQU * 
      LDA IDTLN,I   WRITE OUT THE NEW ID TABLE
      STA MWORD 
      LDA IDTAD 
      LDB LIBD
      JSB DISCZ,I 
      JSB SLVAG,I 
      JMP LEND      TERMINATE.
* 
* 
* CHA# SCANS THE INPUT BUFFER FOR A # FROM 0 TO 65535. IF IT FINDS
* ONE, IT STORES IT IN CHAID,I. IF NO CHARACTER FOLLOWS THE #,
* CHA# TRANSFERS TO CHA10. IF A COMMA FOLLOWS IT RETURNS. IF AN 
* ERROR IS FOUND, IT TRANSFERS TO LFRER. THE 1ST CHARACTER OF 
* THE NUMBER IS IN A UPON ENTRY.
      SPC 1 
CHA#  NOP 
      CLB           INITIALIZE # TO ZERO. 
      STB CHAID,I 
CHA7  ADA M72B      TEST FOR DIGIT. 
      SSA,RSS 
      JMP LFRER     FAIL. 
      ADA .+10
      SSA 
      JMP LFRER     FAIL. 
      STA CHAD      SAVE DIGIT. 
      LDA CHAID,I   GET OLD VALUE.
      MPY .+10       * 10 
      CLE 
      ADA CHAD       + NEW DIGIT. 
      SEZ,SZB,RSS   TEST FOR OVERFLOW.
      RSS           OK
      JMP LFRER     FAIL
      STA CHAID,I   STORE AGAIN.
      JSB T35CH,I   GET NEXT CHAR.
      JMP CHA10     DONE IF CR. 
      CPA .+54B     RETURN IF COMMA.
      JMP CHA#,I
      JMP CHA7      ELSE LOOP.
      SPC 1 
CHAID EQU LTEMP     ID TABLE ENTRY INDEX
CHAI1 EQU LTEMP+1   => PASSWORD OF ID ENTRY 
CHAC  EQU LTEMP+2   PASSWORD WORD COUNTER 
CHAD  EQU LTEMP+3 
* 
* LTEMP+12, LTEMP+13, LTEMP+14 AND LTEMP+15 ARE ALSO USED 
* 
$CHA  EQU * 
      HED SLEEP 
* THE SLEEP COMMAND IS A SYSTEM COMMAND WHICH IS USED FOR SYSTEM
* SHUTDOWN. THE SLEEP ROUTINE PERFORMS THE FOLLOWING FUNCTIONS: 
* 
*     1) PLACE ALL USERS IN DISCONNECT MODE.
*     2) OUTPUT SPECIFIED MESSAGE TO ALL TERMINALS. 
*     3) DISCONNECT ALL USERS.
*     4) LOG OFF ALL ACTIVE USERS.
*     5) FIXUP ALL USER TRACKS AND FUSS.
*     6) GARBAGE COLLECT LIBRARY. 
*     7) DUMP SYSTEM TO MAG TAPE. 
      SPC 2 
      ORG LIBRA 
      CLF 0 
      JMP SLERE 
      BSS 22        ROOM FOR HIBERNATE CODE 
SLERE EQU * 
      LDA SLEST 
      STA CH1       WIPE OUT RECEIVE CHANNEL
      CLA 
      STA T35C1     NO DEBLANKING 
      STA DCLC1,I 
      LDA MLINK 
      STA T35LK 
      LDB DTTY0 
SLE1  LDA DFCHK     CLEAR 
      AND 1,I         BIT FLAG
      STA 1,I           WORD
      ADB .+?STAT 
      LDA %DISC     SET STATUS
      STA 1,I         TO ABORT
      ADB .+?TNUM-?STAT 
      LDA B,I       GET TTY NUMBER
      IOR KAO 
      JSB S14SC,I   KILL OUTPUT 
      ADB .-?TNUM+TTY01-TTY00 
      CPB DTT32     FINISHED ALL USERS? 
      RSS           YES 
      JMP SLE1      NO
      LDA DCLC2,I 
      STA DCLC1,I 
      LDA ONEI      OUTPUT
      LDB DEH        LINE FEED
      JSB TTY35,I 
* 
*  REMOVE USER, IF ANY, FROM THE LINE PRINTER 
* 
      LDA LPD       GET OPCODE
      JSB S14SC,I   TELL I/O PROCESSOR
* 
* OUTPUT SLEEP MESSAGE TO ALL ACTIVE TERMINALS. 
* 
      LDA .+15B     FIRST OUTPUT CR-LF-LF 
      JSB SLECH 
      LDA .+12B 
      JSB SLECH 
      LDA .+12B 
      JSB SLECH 
* 
      JSB T35CQ     GET INPUT CHARACTER.
      JMP *+3       END OF INPUT
      JSB SLECH 
      JMP *-3 
* 
      JSB SLECH     FOLLOW BY ANOTHER CRLFLF. 
      LDA .+12B 
      JSB SLECH 
      LDA .+12B 
      JSB SLECH 
* 
      LDB DTTY0 
      INB 
      LDA M32 
      STA LTEMP+1 
* 
* DISCONNECT ALL USERS
* 
SLE0  LDA HUU       HANG UP 
      IOR 1,I         ALL 
      JSB S14SC,I       USERS 
      ADB .+TTY01-TTY00 
      ISZ LTEMP+1   FINISHED ALL USERS? 
      JMP SLE0      NO
* 
* UPDATE LAST CHANGE DATE 
* 
      CLA           BLOCK CLOCK.
      STA DCLC1,I 
      LDB DTTY0 
SLE7  EQU * 
      STB LTEMP 
      LDA LTEMP,I 
      AND DFCHK 
      SZA,RSS       DATE NEED UPDATING? 
      JMP SLE8      NO
      ADB .+?PROG   YES 
      LDA B,I 
      CMA 
      ADA USE 
      STA MWORD 
      ADB .+?DISC-?PROG 
      LDA B 
      LDB USEI
      JSB DISCZ,I   READ PROGRAM FROM SWAP TRACK
      JMP SLE8      DISC ERROR
      LDA FCNTR 
      CMA,INA 
      LDB LTEMP 
      ADB .+?ID 
      JSB LSD,I     UPDATE LAST CHANGE DATE 
SLE8  EQU * 
      LDB LTEMP 
      CLA 
      STA B,I       ZERO BIT FLAG WORD
      ADB .+TTY01-TTY00 
      CPB DTT32     FINISHED ALL TTYS?
      RSS           YES 
      JMP SLE7      NO
* 
* NOW WE HAVE TO LOG OFF ALL ACTIVE USER. 
* 
      LDA DCLC2,I   UNBLOCK CLOCK.
      STA DCLC1,I 
      LDB DTTY0     SEARCH USER TABLES. 
      ADB .+?ID       FOR ACTIVE IDS. 
      LDA M32 
      STA LTEMP 
SLE2  LDA 1,I       GET ID. 
      SZA,RSS       TEST FOR ACTIVE.
      JMP SLE3      NOT ACTIVE. 
      STB LTEMP+1   SAVE POINTER. 
* 
* COMPUTE TIME USED.
* 
      ADB .+?TIME-?ID 
      DLD 1,I       GET STARTING TIME 
      CMA,INA       SET BOTH PARTS NEGATIVE.
      CMB,INB 
      CLF 0 
      ADA DATIM     A=# OF HRS. USED. 
      CLE 
      ADB DATIM+1   B=# OF UNITS, WITH OVERFLOW IN E. 
      STF 0 
      STB LTEMP+2   SAVE # OF UNITS.
      MPY D60       HRS==> MINS.
      STA LTEMP+3 
      LDA LTEMP+2   GET UNIT COUNT; IF E=0 THEN 
      SEZ,RSS         COUNT AS NEGATIVE 
      CCB 
      DIV D600      CHANGE TO MINUTES.
      ADA LTEMP+3   ADD IN OTHER MINUTES. 
      STA LTEMP+2   TOTAL IN LTEMP(2).
* 
* SEARCH IDT FOR USER.
* 
      LDA LTEMP+1,I GET THIS CLODS ID CODE
      STA ID
      JSB FIDTP,I   FIND WHICH ID TRACK IT IS ON
      JSB SIDTP,I   FIND ID 
* 
* UPDATE IDT ENTRY. 
* 
      ADB .+5       COMPUTER NEW TOTAL TIME.
      CLE 
      LDA 1,I 
      ADA LTEMP+2 
      SEZ           IF OVERFLOW,
      CCA            USE MAXIMUM. 
      STA 1,I 
* 
      LDA LOGCT     CHECK FOR ROOM IN LOG TABLE.
      CPA .+32
      JMP *-2 
      LDA LOGP2     SET LOGP2 TO NEXT LOCATION IN 
      INA            LOG TABLE. 
      CPA LOGND 
      LDA LOGBG 
      STA LOGP2 
      LDA LTEMP+1,I PLACE ID IN LOG TABLE.
      IOR BIT15 
      STA LOGP2,I 
      ISZ LOGP2 
      DLD DATIM     COMPUTE TIME OF DAY.
      STB LTEMP+2   SAVE UNIT COUNTER 
      CLB           GET NO OF HRS.
      DIV .+24
      LDA 1 
      MPY D60       CHANGE TO MINS. 
      STA LTEMP+3   SAVE. 
      LDA LTEMP+2   CHANGE UNITS TO MINS. 
      ADA D36K
      DIV D600
      ADA LTEMP+3   COMPUTE TOTAL TIME. 
      ALF,RAL       ROTATE
      ADA LTEMP     ADD IN PORT NO. 
      ADA .+32
      STA LOGP2,I   STORE IN TABLE. 
      ISZ LOGCT     BUMP COUNTER. 
* 
      LDA IDTAD 
      LDB LIBD
      JSB DISCZ,I   WRITE OUT MODIFIED IDT TRACK
      JSB SLVAG,I 
      LDB LTEMP+1   GET POINTER AGAIN.
SLE3  ADB .+TTY01-TTY00 
      ISZ LTEMP     TEST FOR DONE.
      JMP SLE2
* 
* 
      LDA LOGCT     WAIT FOR LOG TABLE TO EMPTY.
      SZA 
      JMP *-2 
      CPA T35F1     WAIT FOR TTY TO STOP. 
      RSS 
      JMP *-2 
* 
* BRING IN THE LOADER 
* 
      LDB MHAD      FIND
      ADB .+2 
SLE5  LDA B,I         AN
      LDA A,I 
      SZA 
      JMP *+3           ACTIVE
      ADB .+6 
      JMP SLE5            DISC
      ADB .-2 
      DLD B,I       CONVERT 
      CLE,ERA         SECTORS 
      ERB,CLE           TO BLOCKS 
      INB           GET 
      SEZ             BOOTSTRAP 
      INA               ADDRESS 
      DST SLEBA 
      LDA M512      512 WORDS IN
      STA MWORD       BOOTSTRAP 
      LDA SLEBD     READ
      LDB LDBSA 
      ADB BIT15       BOOTSTRAP 
      JSB DISCZ,I 
      JSB SICKP,I 
      LDA .-2       2 PARTS 
      STA SLECT       TO LOADER 
      LDA LSTDA     COMPUTE ADDRESS 
      STA SLETP       OF SEGMENT TABLE
SLE4  DLD SLETP,I   GET LENGTH AND CORE ADDRESS 
      STA MWORD 
      ISZ SLETP 
      ISZ SLETP 
      ADB BIT15 
      LDA SLETP 
      JSB DISCZ,I   READ A PORTION OF THE LOADER
      JSB SICKP,I 
      ISZ SLETP 
      ISZ SLETP 
      ISZ SLECT     FINISHED BOTH PARTS?
      JMP SLE4      NO
* 
      LDA HLT4C     YES, SET POWER
      STA 4           FAIL TO HALT
      CLC 0,C 
SLEHI CLA           A = 0 SEZ SLEEP 
      JMP SLECA,I   TRANSFER TO LOADER DISC DUMP
SLECA OCT 20000 
* 
* 
* 
* SLECH OUTPUTS THE CHARACTER IN A TO ALL ACTIVE
* USER TERMINALS. 
* 
SLECH NOP 
      STA LTEMP     SAVE CHARACTER. 
      LDA M32       SET 
      STA LTEMP+1    COUNTER. 
      LDB DTTY0     GET INITIAL POINTER.
      ADB .+?ID 
SLEC1 LDA 1,I       TEST FOR ACTIVE.
      SZA,RSS 
      JMP SLEC2     INACTIVE. 
      STB LTEMP+2   SAVE POINTER. 
      LDA LTEMP 
      ADB .-?ID 
      JSB OUTCH,I   OUTPUT IT.
      LDB LTEMP+2   GET ID POINTER AGAIN. 
SLEC2 ADB .+TTY01-TTY00 
      ISZ LTEMP+1   TEST FOR DONE.
      JMP SLEC1 
      JMP SLECH,I 
* 
LSD   DEF LCD 
SLEST STC CH1,C     RESPOND TO 2114 SO NO HANG-UP 
SLEBD DEF SLEBA     => BOOTSTRAP DISC ADDRESS 
HLT4C HLT 4,C 
* 
SLECT BSS 1         LOADER PART COUNTER 
SLETP BSS 1         SEGMENT TABLE INDEX 
SLEBA BSS 2         BOOTSTRAP DISC ADDRESS
* 
* LTEMP, LTEMP+1, LTEMP+2 AND LTEMP+3 ARE USED HERE 
* 
$SLE  EQU * 
      HED HIBERNATE 
*     THE HIBERNATE COMMAND IS IDENTICAL TO THE SLEEP COMMAND 
* EXCEPT THAT IT UPDATES THE HDATE WORD IN THE EQUIPMENT TABLE AND
* TELLS THE MAG TAPE SLEEP TO DUMP THE ENTIRE SYSTEM TO TAPE. 
* 
      ORG LIBRA 
      CLF 0 
      LDA MAGSC     CHECK FOR MAG TAPE
      SZA 
      JMP HIBA      TAPE PRESENT, OKAY
* 
      LDA HIBR1     SET UP
      STA MOVES      SOURCE 
      LDA T35B1       AND 
      STA MOVED        DESTINATION
      LDB HIBS1         FOR MOVE ROUTINE
      BRS           MAKE WORD COUNT 
      JSB MOVEW     MOVE MESSAGE INTO BUFFER
      LDA HIBS1     LOAD CHARACTER COUNT
      CMA,INA 
      LDB T35B1 
      JMP LEND2     PRINT ERROR MESSAGE 
HIBR1 DEF *+1 
      OCT 5116
      ASC 5,O MAG TAPE
HIBS1 EQU .+HIBR1-*+HIBR1-*+2 
HIBA  EQU * 
      LDA DATIM     LOAD THE CURRENT TIME AND 
      STA HDATE       SET INTO THE EQUIPMENT TABLE
      ORG SLEHI 
      CCA           A = -1 SEZ HIBERNATE
* 
* ALL TEMPORARIES USED IN 'SLEEP' ARE ALSO USED HERE
* 
