
* 
      SKP 
* 
**
***   RETURN TABLE TO IDT 
**
* 
*  THIS ROUTINE SCANS A TABLE AND UPDATES THE AMOUNT OF DISC SPACE
*  IN USE FOR THE SPECIFIED IDS.  THE FORMAT OF THE TABLE IS: 
*              LIBUS+8192 / (ID)
*                         / LENGTH
*                         / DISC
*                         /   ADDRESS 
*                         . 
*                         . 
*                         . 
* 
*              TECNT - CONTAINS THE NEGATIVE NUMBER OF ENTRIES
* 
RTIDT NOP 
      LDA TECNT     GET CHARACTER 
      STA LSTP2       COUNT AND SAVE
      SZA,RSS       DON'T WASTE TIME
      JMP RTIDT,I     ON A NULL TABLE 
      LDB L8192     => HEAD OF TABLE
      STB LSTP3     SAVE IN POINTER 
RTID1 LDA B,I       GET AND SAVE
      STA ID          NEXT IDCODE 
      JSB FIDT      FIND ID TRACK 
RTID2 JSB SIDT      SEARCH FOR ID 
      SZB,RSS       WAS ID FOUND? 
      JMP RTID3     NO
      ADB .+7       => SECTORS USED 
      LDA LSTP3     => TABLE ENTRY
      INA 
      LDA A,I       = LENGTH TO BE RETURNED 
      CMA,INA       UPDATE
      ADA B,I         DISC SPACE
      STA B,I           USED
      LDB LSTP3     SET POINTER 
      ADB .+4         TO NEXT 
      STB LSTP3         ENTRY 
      LDA B,I       GET AND 
      STA ID          SAVE ID 
      ISZ LSTP2     DONE? 
      JMP RTID2     NO
* 
RTID3 LDA IDTAD     => DISC ADDRESS 
      LDB LIBD      WRITE OUT 
      JSB DISCZ,I     ID TRACK
      JSB DEADP,I   BAD NEWS
      LDA LSTP2     WORK ALL DONE?
      SZA,RSS 
      JMP RTIDT,I   YES - RETURN
      LDB LSTP3     NO, PROCESS 
      JMP RTID1       NEXT ENTRY
      SKP 
* 
**
***   SET UP HEADING
**
* 
*  HDBUF SETS UP THE HEADING FOR DIRECTORY, STATUS, AND REPORT
*  ON THE SYSTEM CONSOLE.  THE HEADING CONSISTS OF THE SYSTEM 
*  ID, DATE, AND TIME.
* 
HDBUF NOP 
      LDA T35B1     INITIALIZE TTY
      STA LTEMP+9     BUFFER POINTER
      LDA LFSPA     LF-SPACE
      STA LTEMP+9,I 
      LDA ASCBB     TWO SPACES
      ISZ LTEMP+9 
      STA LTEMP+9,I 
      LDA T35B1     MOVE
      ADA .+2 
      STA MOVED       SYSTEM
      LDA DSYID 
      STA MOVES         ID TO 
      LDB .-5 
      JSB MOVFW,I         BUFFER
      LDA ASCBB     TWO SPACES
      LDB LTEMP+9 
      ADB .+6 
      STA B,I 
      ADB .+2 
      STB LTEMP+9 
      LDA DATIM     GET HOUR OF YEAR
      CLB           CONVERT 
      DIV .+24        TO DAY
      STB LTEMP+10  SAVE HOUR REMAINDER 
      CLB           GET LAST
      DIV .+10        DIGIT 
      BLF,BLF 
      ADB ZERSL     MERGE IN SLASH
      STB LTEMP+9,I 
      JSB TDNUM     FIRST TWO DIGITS OF DAY 
      CCB 
      ADB LTEMP+9 
      STA B,I 
      ADB .+2 
      STB LTEMP+9 
      LDA YEAR      YEAR OF CENTURY 
      JSB TDNUM 
      STA LTEMP+9,I 
      LDA ASCBB     TWO SPACES
      ISZ LTEMP+9 
      STA LTEMP+9,I 
      LDA LTEMP+10  HOUR OF DAY 
      JSB TDNUM 
      ISZ LTEMP+9 
      STA LTEMP+9,I 
      LDA DATIM+1   CONVERT 
      ADA D36K        100 MS
      CLB               UNITS TO
      DIV D600            MINUTES 
      JSB TDNUM             OF HOUR 
      ISZ LTEMP+9 
      STA LTEMP+9,I 
      LDA .+28      28 CHARS IN HEADING 
      LDB T35B1 
      JMP HDBUF,I 
* 
* CONVERT A NUMBER <100 TO ASCII
* 
TDNUM NOP 
      CLB 
      DIV .+10
      ALF,ALF       FIRST DIGIT 
      ADA B         SECOND DIGIT
      ADA ASC00     ASCII OFFSET
      JMP TDNUM,I 
      SKP 
* 
**
***   PRINT HEADING 
**
* 
*  UHDBF PRINTS THE HEADING FOR DIRECTORY, STATUS, AND REPORT 
*  ON THE USER TERMINAL.  THE HEADING CONSISTS OF THE SYSTEM
*  ID, DATE, AND TIME.
* 
UHDBF NOP 
      LDA .+12B     LF
      JSB LOUTA,I 
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA DSYID 
      STA LTEMP+8   => SYSTEM ID
      LDA .-5 
      STA LTEMP+9   5 WORDS 
UHDB1 EQU * 
      LDA LTEMP+8,I OUTPUT
      ALF,ALF 
      AND B377
      JSB LOUTA,I     SYSTEM
      LDA LTEMP+8,I 
      AND B377
      JSB LOUTA,I       ID
      ISZ LTEMP+8 
      ISZ LTEMP+9 
      JMP UHDB1 
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA DATIM     GET HOUR OF YEAR
      CLB 
      DIV .+24      CONVERT TO DAY
      STB LTEMP+9   SAVE HOUR REMAINDER 
      CLB 
      DIV .+10      1ST 2 DIGITS IN A, LAST IN B
      STB LTEMP+8 
      JSB UTDNM     OUTPUT 1ST 2
      LDA LTEMP+8 
      ADA .+60B 
      JSB LOUTA,I   OUTPUT LAST ONE 
      LDA .+57B     '/' 
      JSB LOUTA,I 
      LDA YEAR      GET YEAR
      JSB UTDNM       AND OUTPUT
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA .+40B     BLANK 
      JSB LOUTA,I 
      LDA LTEMP+9   HOUR OF DAY 
      JSB UTDNM 
      LDA DATIM+1   CONVERT 
      ADA D36K        100MS 
      CLB               UNITS TO
      DIV D600            MINUTES 
      JSB UTDNM             OF HOUR 
      LDA .+23B     X-OFF 
      JSB LOUTA,I 
      LDA .+15B     CR
      JSB LOUTA,I 
      LDA .+12B     LF
      JSB LOUTA,I 
      JMP UHDBF,I 
* 
* CONVERT A #<100 TO ASCII AND OUTPUT IT
* 
UTDNM NOP 
      CLB 
      DIV .+10
      STB LTEMP+11
      ADA .+60B 
      JSB LOUTA,I 
      LDA LTEMP+11
      ADA .+60B 
      JSB LOUTA,I 
      JMP UTDNM,I 
      HED UPDATE LAST CHANGED DATE ROUTINE
* 
*     UPDATE LAST CHANGED DATES IF NECESSARY
* 
#LCDL EQU * 
      LDB MLINK+1   IS THERE
      ADB .-?LINK     A NEED TO 
      LDA B,I           CHECK FILES 
      AND DFCHK           FOR POSSIBLE
      SZA,RSS               LCD UPDATE
      JMP EXIT7 
      ADB .+?PLEV 
      CLA 
      CLF 0 
      STA B,I       SET PRIORITY TO 0 
      STA TIMEF     NO TIMING 
      ADB .+?STAT-?PLEV 
      LDA %SYNT     SET STATUS TO SYNTAX SO 
      STA B,I         WE WON'T GET SWAPPED
      ADB .+?PROG-?STAT 
      LDA PBPTR       BOUND INTO
      STA B,I           TTY TABLE 
      CMA           CALCULATE LENGTH
      ADA USE         FOR WRITE 
      STA MWORD         TO DISC 
      ADB .+?DISC-?PROG 
      LDA B         => SWAP TRACK DISC ADDRESS
      LDB USE       OUTPUT USER 
      JSB DISCZ,I     TO DISC 
      JMP PTZAP,I   BLEW IT, GO ZAP USER
      LDA FRMAT     GET FILE COUNT (-)
      LDB MLINK+1   GET POINTER 
      ADB .+?ID-?LINK           TO ID WORD
      JSB LCD       GO UPDATE LAST CHANGED DATES
      JMP EXIT7     CORE INTACT, EXIT 
      CLA           BLOCK 
      STA DCLC1,I     CLOCK 
      LDA MLINK+1   RESTORE 
      ADA .+?PROG-?LINK 
      LDB A,I         USER
      CMB 
      ADB USE 
      STB MWORD         SWAP
      ADA .+?DISC-?PROG 
      LDB USEI
      JSB DISCZ,I         AREA
      JMP PTZAP,I   BLEW IT, GO ZAP USER
EXIT7 EQU * 
      JSB ABCK,I    CHECK FOR ABORTS
      JMP LCDLP,I 
      SKP 
* 
*     THIS ROUTINE ASSUMES THAT THE USER'S SWAP AREA IS IN CORE,
*     THAT THE B REGISTER POINTS TO HIS ID WORD IN THE TELETYPE 
*     TABLE, AND THAT A CONTAINS THE NEGATIVE OF THE NUMBER OF FILES
* 
* 
LCD   NOP           ENTRY POINT 
      STA LCDFC     SAVE FILE COUNT 
      STB LCDID       AND ID POINTER
      SSA,RSS       MAKE SURE THERE REALLY ARE
      JMP LCD9          SOME FILES
      CLA           INITIALIZE DIRTY
      STA DFCNT       FILE COUNT TO ZERO
      LDA DFNAM     GET ADDRESS FOR FIRST 
      STA MOVED       DIRTY FILE'S NAME 
      LDB FILTB     GET START OF FILE TABLE 
      INB           BUMP POINTER TO WORD 1
      STB LCDBS       OF ENTRY AND SAVE 
* 
LCD1  LDA B,I       GET DIRTY FILE BIT
      AND BIT14     HAS THIS FILE 
      SZA             BEEN CHANGED? 
      JMP LCD2      YES 
LCD3  ADB .+FTEL    NO, POINT TO NEXT ENTRY 
      ISZ LCDFC     ARE THERE MORE FILES? 
      JMP LCD1      YES, CHECK NEXT ONE 
      LDA DFCNT     NO, WERE
      SZA,RSS         ANY DIRTY?
      JMP LCD9      NO, RETURN
* 
      ISZ LCD       YES, BUMP RETURN (CORE IS DIFF) 
      CMA,INA       SAVE NEGATIVE OF
      STA DFCNT       DIRTY FILE COUNT
      LDB DFNAM     GET ADDRESS OF FIRST
      STB LCDBS       DIRTY FILE'S NAME 
      LDA LCDID,I   STICK ID IN LTEMP 
      STA LTEMP       FOR DLOOK 
LCD6  LDA B,I       MOVE DIRTY
      STA LTEMP+1    FILE'S 
      INB             NAME
      DLD B,I          INTO 
      DST LTEMP+2       LTEMPS
      JSB DLOKA,I   GO HUNT FOR DIRECTORY ENTRY 
      JMP LCD5      FOUND IT
LCD7  LDB LCDBS     BUMP
      ADB .+3         POINTER TO
      STB LCDBS         NEXT NAME 
      ISZ DFCNT     MORE DIRTY FILES? 
      JMP LCD6      YES, PROCESS NEXT ONE 
* 
      LDA DIRWD     NO, WRITE DIRECTORY TO
      SZA,RSS         DISC IF ANY IS IN CORE
      JMP LCD9      ELSE, RETURN
      CLB           TELL DLOOK
      STB DIRWD       THERE ISN'T 
      LDB LIBD      WRITE TRACK 
      JSB DISCZ,I     TO DISC 
      JSB SLVAG,I   BAD NEWS, TRY TO SALVAGE
LCD9  LDB LCDID     CLEAR 
      ADB .-?ID      CHECK
      LDA DFCHK       FOR 
      CLF 0            DIRTY
      XOR B,I           FILES 
      STA B,I            BIT
      STF 0 
      JMP LCD,I     RETURN
* 
*     MOVE NAME OF DIRTY FILE TO SAFE PLACE 
* 
LCD2  ISZ DFCNT     BUMP DIRTY FILE COUNT 
      STB LCDBS     SAVE POINTER TO FILE TABLE ENTRY
      ADB .+10      GET POINTER TO FILE NAME
      STB MOVES       AND SET IN MOVEW'S SOURCE ADR 
      LDB .-3       MOVE THE 3
      JSB MOVFW,I     NAME WORDS
      LDB LCDBS     GET ENTRY POINTER BACK
      JMP LCD3      RETURN TO SCAN OF FILE TABLE
* 
*     PROCESS A FOUND DIRECTORY ENTRY 
* 
LCD5  LDA LTEMP+4   TELL DLOOK WHICH
      ADA .+5         DIRECTORY TRACK 
      STA DIRWD         IS IN CORE
      LDB LTEMP+5   GET 
      ADB .+2         WORD
      LDA B,I           2 
      SSA,RSS       IS THE ENTRY A FILE?
      JMP LCD7      NO, GO PROCESS NEXT NAME
      ADB .+4       YES, UPDATE LAST
      LDA DATIM       CHANGED DATE IN 
      STA B,I           DIRECTORY ENTRY 
      JMP LCD7      GO PROCESS NEXT NAME
      SKP 
* 
*  THIS ROUTINE SETS UP THINGS TO UPDATE THE LAST CHANGE DATE 
*  WHEN A USER HAS ABORTED
* 
ABUCD LDA MAIN
      ADA .+?PROG 
      LDB PBPTR     SET BOUND IN
      STB A,I         TTY TABLE 
      CMB 
      ADB USE       COMPUTE AND SET 
      STB MWORD       TRANSFER LENGTH 
      ADA .+?DISC-?PROG  => DISC ADDRESS
      LDB USE       WRITE SWAP
      JSB DISCZ,I     TRACK TO DISC 
      JMP PTZAP,I   BLEW IT, FLUSH USER 
      LDA FCNTR 
      CMA,INA       -# OF FILES 
      LDB MAIN
      ADB .+?ID     => ID WORD IN TTY TABLE 
      JSB LCD       UPDATE LAST CHANGE DATE 
      NOP 
      CLF 0 
      LDB MAIN
      STB TTQ       FOR SCHEDULER 
      LDA UNABT 
      IOR ABTRY 
      CMA 
      AND B,I 
      STA B,I       CLEAR ABORT FLAGS 
      CLA 
      STA MAIN      USER NO LONGER IN CPRE
      STA DCLC1,I   BLOCK CLOCK 
      ADB .+?STAT   => STATUS WORD
      JMP DSCH7,I   ENTER ABORT CODE IN SCHEDULER 
* 
      SPC 3 
      SUP 
MLKFL EQU * 
      LDA .+25
      LDB *+2 
      JMP LEN2A,I 
      DEF *+1 
      OCT 5114
      ASC 12,OCKED BLOCKS TABLE FULL
      SPC 1 
DDERL EQU * 
      OCT 5104
      ASC 11,ISC ERROR; CAN'T DO IT 
      UNS 
      SPC 1 
FILBF BSS 131       FILE BUFFER 
      BSS 0 
