      HED   MOVE OVERLAY
* 
*     THE MOVE OVERLAY DOES THE ACTUAL MOVING 
* OF THE PROGRAM
* qq
      SPC 2 
      ORG LIBRA 
      SPC 1 
      JSB FDIRC     GET DIREC 
      LDB LTEMP+4,I   TRACK 
      SZB,RSS       EMPTY?
      JMP MOV.B     YES - GO BACK ONE 
      LDA DLTEM     ON THIS TRACK?
      LDB LTEMP+4 
      INB 
      JSB DIRCM 
      JMP MOV.B     NO - GO BACK ONE TRACK
      NOP                             (L) 
MOV.D LDA LTEMP     YES 
      IOR BIT15       LOOK
      STA LTEMP         FOR 
      JSB DLOOK           IT
      JMP LEND      ALREADY THERE 
      LDA LTEMP     FOUND WHERE IT GOES 
      ELA,CLE,ERA 
      STA LTEMP PV
      JMP MOV.H 
MOV.B LDB LTEMP+4   GO BACK 
      ADB .-7         ONE 
      STB LTEMP+4       TRACK 
      JMP MOV.D 
* 
*     WE HAVE FOUND WHERE THE NEW ENTRY 
*     FITS, SO PUT IT IN
* 
MOV.H EQU * 
      LDB LTEMP+4   MAKE
      LDA 1,I         SURE
      STA WORD          DIRECTORY 
      ADB .+6             TRACK 
      LDA 1,I               IS
      LDB LIBDI               IN
      JSB DISCL                 CORE
      LDB LTEMP+4,I 
      CPB M4560                                   (D) 
      JMP MVSUP     IF TRACK FULL THEN SUPERSAVE
      CMB 
      ADB LIBD
       STB MOVES   SET SOURCE ADR 
      ADB .+8 
      STB MOVED     SET DESTINATION ADDRESS 
      LDB MOVES     COMPUTE 
      CMB,INB         LENGTH
      ADB LTEMP+5 
      ADB .+7 zz
      JSB MOVEB     MOVE UP DIRECTORY 
* 
      LDA LTEMP+5  MOVE NEW 
      ADA .+8      ENTRY INTO 
      STA MOVED    POSITION 
      LDA DLTEM 
      STA MOVES 
      LDB .-4 
      JSB MOVEW 
* 
      LDA MPROG    SET IN PROG START
      STA MOVED,I 
      LDA MPURG    STORE DATE 
      ISZ MOVED 
      STA MOVED,I 
      ISZ MOVED 
      LDA MADT     STORE AND LENGTH 
      LDB MOVWD    ADDRESS AND LENGTH 
      DST MOVED,I 
      LDB LTEMP+4  UPDATE DIRECTORY 
      STB MOVED    TRACK
      LDA 1,I      LENGTH 
      ADA .-8 
      STA 1,I 
      STA WORD
      ADB .+6 
      LDA 1,I 
      LDB LIBD
      JSB DISCL    OUTPUT DIREC TO DISC 
* 
      ISZ MOVED 
      LDB LIBD
      STB MOVES 
      LDB .-4      UPDATE B.P. DIREC. 
      JSB MOVEW 
* qq
*     READ IN ADT TABLE+UPDATE
* 
      LDA ADLEN 
      STA WORD
      LDA ADLOC 
      LDB LIBDI 
      JSB DISCL    READ IN ADT
* 
      LDB LIBD
      LDA 1,I      GET ENTRY
      CPA MADT     IS THIS THE NEW ENTRY
      JMP *+3      YES
      ADB .+2 
      JMP *-4      NEXT ENTRY 
* *q
      LDA MOVLN 
      CMA,INA 
      ADA MADT
      STA 1,I 
      LDA MOVLN    RESET NEW LENGTH 
      ADA MADT+1   INTO ADT ENTRY 
      INB 
      STA 1,I 
      SZA          IS IT ZERO?
      JMP MOV.7    NO - GO LOOK FOR L OLD ONE 
      INB          YES-DELETE IT
      STB MOVES 
      STB 0 
      ADB .-2 
      STB MOVED 
      ADA ADLEN 
      LDB LIBD
      CMB,INB 
      ADB 0 0
      JSB MOVEW    COMPACT ADT TABLE
      ISZ ADLEN    REDUCE LENGTH
      ISZ ADLEN 
* 
*     NOW SEARCH FOR OLD ENTRY POSITION 
* 
MOV.7 LDB LIBD\\
      LDA MOVD1 
      AND DHMSK 
      STA MOVDS 
MV.C  EQU * 
      LDA 1,I      LOAD ENTRY 
      AND DHMSK      RIGHT
      CPA MOVDS        DISC?
      JMP MV.B
      ADB .+2      NO- NEXT ENTRY 
      JMP MV.C.|
MV.B  EQU * 
      LDA 1,I      RELOAD ADT ENTRY 
      AND DHMSK                       (L) 
      CPA MOVDS   SAME SUB-CHANNEL?   (L) 
      RSS         YES, CONT. SEARCH   (L) 
      JMP MOV.8   NO
      LDA 1,I 
      CMA,INA 
      ADA MOVD1    ARE WE BEYOND OLD ENTRY
      SSA 
      JMP MOV.8    YES INSERT ENTRY 
      ADB .+2 
      JMP MV.B.@
MOV.8 STB MVADT    SAVE ADDRESS 
      LDA MOVLN    LOAD LENGTH
      CMA,INA      POSITIVE SECTORS 
      ADA MOVD1    ADD DISC ADDRESS 
      CPA MVADT,I  ADJACENT?
      JMP MOV.9    YES
      ADB .-2      GO BACK TO PREVIOUS
      LDA 1,I      LOAD DISC ADDRESS
      INB 
      ADA 1,I      ADD LENGTH 
      CPA MOVD1    ADJACENT?
      JMP MOV10    YES
* 
*     THE NEW ADT ENTRY IS NOT ADJACENT 
*     TO ANY OTHERS, SO SEPARATE TABLE
*     AND INSERT NEW ENTRY
* 
      LDB ADLEN     MOVE
      CMB             ADT 
      ADB LIBD          APART 
      STB MOVES 
      ADB .+2 
      STB MOVED 
      CMB,INB 
      INB 
      ADB MVADT 
      JSB MOVEB    SEPARATE ADT TABLES
      LDA MOVD1    SET NEW ADDRESS
      STA MVADT,I 
      LDA MOVLN 
      CMA,INA A&
      ISZ MVADT    SET LENGTH 
      STA MVADT,I 
      LDA .-2      RESET
      ADA ADLEN    ADT TABLE
      STA ADLEN    LENGTH 
      JMP MOV11 
*     THE NEW ENTRY IS ADJACENT TO THE
*     NEXT ONE
* qq
MOV.9 LDA MOVD1    SET NEW ADDRESS
      STA 1,I      INTO TABLE 
      LDA MOVLN    COMPUTE NEW
      CMA,INA      LENGTH 
      INB          AND STORE
      ADA 1,I      IN TABLE 
      STA 1,I 
* 
      ADB .-3      CHECK IF PREVIOUS
      LDA 1,I      ENTRY IS ADJACENT
      INB 
      ADA 1,I 
      CPA MVADT,I 
      RSS          YES
      JMP MOV11 1-
      ADB .+2      COMPUTE NEW
      LDA 1,I      LENGHT 
      ADB .-2      (ADDRESS IS
      ADA 1,I      CORRECT AS IS) 
      STA 1,I 
* 
*     NOW COMPACT TABLE 
* qq
      LDA MVADT    SET UP FOR 
      STA MOVED    MOVEW SUBROUTINE 
      ADA .+2 
      STA MOVES 
      LDB LIBD     COMPUTE # OF 
      CMB,INB      WORDS TO MAVE
      ADB ADLEN 
      ADB MVADT 
      ADB .+2 
      JSB MOVEW    NOVE TABLE DOWN
      ISZ ADLEN    RESET TABLE
      ISZ ADLEN    LENGTH 
      JMP MOV11 1-
* qq
*     NEW ENTRY IS ADJACENT TO PREVIOUS 
*     ENTRY BUT NOT TO NEXT ENTRY 
* qq
MOV10 LDA MOVLN    RESET LENGTH 
      CMA,INA      (ADDRESS IS OK)
      ADA 1,I 
      STA 1,I 
* 
*     THE ADT HAS BEEN RESET
*     NOW DELET OLD DIRECTORY ENTRY 
* 
MOV11 LDA ADLEN 
      STA WORD
      LDA ADLOC 
      LDB LIBD
      JSB DISCL 
      LDA MV.LN 
      STA WORD
      LDA LIB 
      ADA .+2 
      LDA 0,I 
      LDB #LIBI 
      JMP MOV15 
MVSUP ISZ MFLAG     SET FLAG TO INDICATE ERROR
      LDA M252      MESSAGE TO GO TO CONSOLE. 
      STA WORD      LOAD "SUPER SAVE" 
      LDA MOV17,I 
      LDB #LIBI 
      JMP LIBRA+252 
MOV15 JSB DISCL 
      JMP LIBRA 
MV.LN ABS LIBRA-$$$MV 
MOV17 DEF SAVE+1+COM6-COM3  POINTER TO "SUPER SAVE" 
M4560 DEC -4560                                   (D) 
      ORG LIBRA+252 
      JSB DISCL 
      JMP LIBRA 
      JMP MOV.G 
* 
MOVD1 EQU LTEMP+7 
MOVLN EQU LTEMP+8 
MVADT EQU LTEMP+9 
MOVDS EQU LTEMP+10
MADT  EQU LTEMP+11
MPURG EQU LTEMP+13
MPROG EQU T35BF+31
MOVCT EQU T35BF+35
MOVPT EQU T35BF+34
MOVWD EQU T35BF+33
MOVSB EQU T35BF+32
$$MOV EQU * 
      HED   MOVE OVERLAY #2 2,
      ORG LIBRA 
      SPC 2 
      LDA MOVD1 
      AND DHMSK 
      STA LTEMP+6 
      JSB FDIRC    COMPUTE DIRECTORY
* 
      LDA LTEMP    SET UP TO LOOK 
      IOR BIT15    FOR ONLY 1 TRACK 
      STA LTEMP PV
      LDA LTEMP+4,I 
      SZA,RSS      EMPTY TRACK
      JMP MOV13    GO TO NEXT ONE 
      LDA DLTEM    NOW CHECK IF 
      LDB LTEMP+4  ENTRY IS ON
      INB          THIS TRACK 
      JSB DIRCM 
      JMP MOV13    NO 
      NOP                             (L) 
MOV14 JSB DLOOK    YES-FIND IT
      RSS 
      JMP LFRER    WHAT HAPPENED TO MY PROG?
      LDB LTEMP+5   READ IN THE PROGRAM 
      ADB .+7 
      LDA 1,I 
      STA WORD
      STA MOVCT 
      ADA P3072 
      SSA 
      JMP TOMCH 
      ADB .-1 
      LDA 1,I 
      LDB LIBDI 
      JSB DISCL 
      LDA MADT      WRITE TO
      LDB LIBD        NEW 
      JSB DISCL         LOCATION
MOV16 EQU * 
      LDB LTEMP+4   RELOAD
      LDA 1,I         DIRECTORY TRACK 
      STA WORD          TRACK 
      ADB .+6 6$
      LDA 1,I 
      LDB LIBDI 
      JSB DISCL 
* 
*     THE OLD ENTRY HAS BEEN FOUND, DELETE IT.
* 
      LDA LTEMP+5  MOVE DIRECTORY 
      STA MOVED    DOWN.
      ADA .+8 
      STA MOVES 
      LDB LIBD
      CMB,INB 
      ADB LTEMP+4,I 
      ADB LTEMP+5 
      ADB .+8 
      JSB MOVEW    MOVE!
      LDA LTEMP+4,I 
      ADA .+8 
      STA LTEMP+4,I 
      STA WORD
      LDB LTEMP+4 
      ADB .+6 
      LDA 1,I I
      LDB LIBD
      STB MOVES 
      JSB DISCL    WRITE DIRECTORY TO DISC
      LDA LTEMP+4 
      INA 
      STA MOVED 
      LDB .-4 4W
      JSB MOVEW    RESET B.P. DIREC.
* 
*     WE ARE NOW ALL DONE!
*     WHEW!  (YOU CAN SAY THAT AGAIN!)
* 
      CLF 0 
      ISZ LIB       SAY MOVE NOT IN CORE
      JMP LEND      END OF MOVE 
MOV13 LDA LTEMP+4  POINT TO 
      ADA .-7        NEXT DIRECTORY 
      STA LTEMP+4     TRACK BACK
      JMP MOV14    GO FIND PROG 
TOMCH LDA M3072 
      STA WORD
      ADB .-1 
      LDA 1,I 
      STA MOVDS 
      LDB LIBDI 
      JSB DISCL 
      LDA MADT
      LDB LIBD
      JSB DISCL 
      LDA MOVCT 
      ADA P3072 
      STA WORD
      LDA MOVDS 
      ADA .+24
      LDB LIBDI 
      JSB DISCL 
      LDA MADT
      ADA .+24::
      LDB LIBD
      JSB DISCL 
      JMP MOV16 
$$$MV EQU * 
      HED PURGE 
* THE PURGE COMMAND MAKES IT POSSIBLE TO REMOVE FROM THE LIBRARY
* PROGRAMS WHICH HAVE NOT BEEN ACCESSED FOR SOME PERIOD OF TIME.
* THE FORMAT FOR THE COMMAND IS AS FOLLOWS: 
* 
*     PURGE-DAY/YEAR
* 
* WHERE DAY IS AN INTEGER FROM 1 TO 366 AND YEAR IS AN INTEGER FROM 
* 0 TO 99. ALL PROGRAMS OR FILES WHICH HAVE NOT BEEN ACCESSED SINCE 
* THE SPECIFIED DATE ARE DELETED FROM THE LIBRARY.
* qq
* PURGE WILL REFUSE TO OPERATE IF THE SPECIFIED DATE IS BEYOND
* TODAY'S DATE. 
* qq
* THE ALGORITHM USED OPERATES IN A MANNER ALMOST IDENTICAL TO THAT
* USED IN THE LOCK OVERLAY SECTION, EXCEPT THAT THE ADT MUST BE 
* UPDATED IN ADDITION TO THE IDT.  THE ACTUAL UPDATING OF THESE IS
* PERFORMED BY CALLING THE ROUTINE PURFX, WHICH READS IN THE PURGE
* OVERLAY ROUTINE TO DO THE UPDATING. 
      SPC 3 3h
      ORG LIBRA 
      LDA A000      IF HELLO PROGRAM
      STA LTEMP      EXISTS, ASSIGN IT
      LDA PURHE       TODAY'S DATE SO IT
      STA LTEMP+1      DOESN'T GET PURGED.
      DLD PURHE+1 
      DST LTEMP+2 
      JSB DLOOK 
      RSS 
      JMP PUR2
      JSB DATE
      LDB LTEMP+5 
      ADB .+5 
      STA 1,I 
      LDA LTEMP+4 
      ADA .+6 
      LDA 0,I 
      LDB LIBD
      JSB DISCL 
* 
* INTERPRET DATE. 
* qq
PUR2  JSB PURNO     GET DAY OF YEAR.
      DEC -367
      CPA .+57B     TEST FOR NONZERO AND SLASH FOL- 
      SZB,RSS        LOWING.
      JMP PUR1      PARAMETER ERROR.
      STB PURDT     SAVE DATE.
      JSB PURNO     NOW GET THE YEAR. 
      DEC -100
      CPA .+15B     CHECK FOR RETURN FOLLOWING. 
      CLA,RSS 
      JMP PUR1
* 
      RRR 7         MERGE YEAR AND DATE.
      IOR PURDT 
      STA PURDT 
      JSB DATE      NOW GET TODAY'S DATE. 
      LDB PURDT     MAKE SURE SPECIFIED DATE IS 
      CMB,CLE,INB    <=TODAY'S DATE 
      ADA 1 
      SEZ,RSS 
      JMP PUR1
* q{
* THE NEXT STEP IS TO GUARANTEE THAT WE DON'T KILL ANY FILES CUR- 
* RENTLY IN USE. TO DO THIS WE WILL CHECK THAT THE FUSS TABLE IS
* EMPTY.
* 
      LDA M128     INPUT FUSS 
      STA WORD       TABLE. 
      LDA FUSS,I
      LDB LIBDI 
      JSB DISCL 
* qq
      LDB LIBD
PUR4  CPB L128     DONE?
      JMP PUR3      YES.
      LDA 1,I 
      SZA 
      JMP PUR7
      INB 
      JMP PUR4
* 
* ROUTINE TO INPUT A NUMBER 
* 
PURNO NOP PY
      JSB PURDG     GET A DIGIT 
      JMP LFRER     ILLEGAL IF NONE.
PURN1 STB PURN      SAVE PARTIAL RESULT.
      ADB PURNO,I   CHECK FOR OVERFLOW. 
      SSB,RSS 
      JMP PUR1
      JSB PURDG     GET NEXT DIGIT. 
      JMP PURN2     END OF NUMBER.
      LDA PURN      MULTIPLY PREVIOUS RESULT BY 10. 
      RAL,RAL 
      ADA PURN
      RAL 
      ADB 0         ADD IN NEW VALUE
      JMP PURN1     LOOP
PURN2 LDB PURN      RETURN NO.
      ISZ PURNO 
      JMP PURNO,I 
* 
* 
PURDG NOP           GET DECIMAL DIGIT 
      JSB T35CQ     GET CHAR. 
      JMP PURDG,I   NONE THERE. 
      LDB 0         DO DIGIT TEST.
      ADB M72B
      SSB,RSS 
      JMP PURDG,I 
      ADB .+10
      SSB,RSS 
      ISZ PURDG G
      JMP PURDG,I 
* 
* ERROR PRINT.
* qq
PUR1  LDB .-181.
      JSB PURER 
      OCT 5111
      ASC 8,LLEGAL PARAMETER
PUR7  LDB .-11
      JSB PURER 
      OCT 5102
      ASC 6,USY FILES 
PURER NOP xxxi
      STB PURN
      LDA T35B1 
      STA MOVED 
      LDA PURER 
      STA MOVES 
      BRS 
      JSB MOVEW 
      LDA PURN
      CMA,INA 
      LDB T35B1 
      JMP LEND2 
* qq
PUR3  EQU * 
      LDA M3072     COMPUTE NEGATIVE
      LDB M3072       POINTER TO TEST 
      CMB,INB         WHEN PURFX MUST 
      ADB ADLEN        BE CALLED. 
      SSB 
      LDA ADLEN 
      ADA MLIBD 
      ADA .-4 
      STA PURID 
* 
      LDA USEND     INITIATE POINTER TO 
      STA PURP       END OF CORE TABLE. 
      LDA DIRD0     INITIALIZE DIRECTORY POINTER. 
PUR10 STA PURI
      LDA PURP      CAN DIRECTORY FIT?
      ADA PURI,I
      ADA MLIBD 
      SSA 
      JSB PURFX     NO--PERFORM CLEARNUP. 
      LDA PURI,I    READ DIRECTORY. 
      STA WORD
      LDA PURI
      ADA .+6 
      LDA 0,I 
      STA PURDD 
      LDB LIBDI 
      JSB DISCL 
* 
      LDA LIBD      INITIALIZE POINTERS.
      STA MOVED 
      STA MOVES 
      CMA 
      ADA PURI,I
      CMA 
      STA PURD
* qq
PUR11 LDB MOVES     FINISHED SCANNING DIRECTORY?
      CPB PURD
      JMP PUR12     YES.
      ADB .+5       DO WE WANT TO DELETE THIS ENTRY?
      LDA PURDT 
      CMA,CLE,INA 
      ADA 1,I 
      SEZ,RSS 
      JMP PUR13     YES.
      LDB .-8       NO-MOVE UP ENTRY
      JSB MOVEW 
      JMP PUR11 
* 
* ENTRY DELETION. 
* 
PUR13 LDA MOVES,I   COPY ID,DISC ADR.,LENGTH INTO T.
      STA PURT
      ADB .+3 3;
      STB MOVES 
      ADB .-2 
      DLD 1,I 
      STA PURT+1
      ASR 7                                      X] 
      CMB,INB 
      STB PURT+2
* 
      LDA PURD      CAN NEW ENTRY FIT IN WITH THE 
      CMA,INA        DIRECTORY? 
      STA 1 
      ADA .-3 
      ADA PURP
      SSA,RSS 
      JMP PUR14     YES--GO DO NEXT TEST. 
* qq
* SQUEEZE DIRECTORY.
* 
      LDA MOVED     SAVE DEST 
      STA PURN       POINTER. 
      ADB MOVES     MOVE REMAINDER
      JSB MOVEW      OF DIRECTORY.
      LDA MOVED     RESET 
      STA PURD       POINTERS.
      LDA PURN
      STA MOVED 
      STA MOVES 
* *q
PUR14 LDA PURP      WILL IDT AND ADT STILL FIT IF 
      ADA PURID      WE MAKE ANOTHER ENTRY? 
      SSA,RSS 
      JMP PUR15     YES.
* 
      LDA PURD      WRITE OUT DIRECTORY.
      CMA,INA 
      ADA LIBD
      STA WORD
      STA PURW
      LDA PURDD 
      LDB LIBD
      JSB DISCL 
* qq
      JSB PURFX     CLEAN UP. 
* 
      LDA PURW      READ
      STA WORD       DIRECTORY
      LDA PURDD       BACK. 
      LDB LIBDI 
      JSB DISCL 
* qq
PUR15 CCB           MAKE TABLE ENTRY. 
      ADB PURP
      LDA PURT+2
      STA 1,I 
      ADB .-2 
      STB PURP
      DLD PURT
      DST PURP,I
      JMP PUR11 
PUR12 LDA MOVED     UPDATE DIREC. 
      CMA,INA A&
      ADA LIBD
      STA PURI,I
      STA WORD
      LDA LIBDB
      STA MOVES 
      LDA PURI
      INA 
      STA MOVED 
      LDB .-4 
      JSB MOVEW 
      LDA PURDD     WRITE OUT DIRECTORY.
      LDB LIBD
      JSB DISCL 
      LDA PURI      LAST TRACK? 
      CPA DIRD3 
      JMP *+3 
      ADA .+7 
      JMP PUR10 0b
      JSB PURFX Xl
      JMP LEND
PURXF LDA PURLN     GET BACK TO PURGE.
      STA WORD
      LDA LIB,I 
      LDB #LIBI 
      JSB DISCL 
      JMP PURFX,I 
* 
PURFX NOP           ROUTINE TO CALL IN OVERLAY. 
      DLD LIB,I 
      LDA 1 
      LDB PURLN 
      STB WORD
      LDB #LIBI 
      JSB DISCL 
      JMP LIBRA 
PURLN ABS LIBRA-PURXF 
PURHE ASC 3,HELLO 
$PUR  EQU * 
