
      HED MUNLOCK 
* THE MUNLOCK COMMAND IS USED TO RESTORE TO THE SYSTEM ANY DISC 
* BLOCKS WHICH HAVE PREVIOUSLY BEEN MLOCKED. THE FORMAT FOR THE 
* COMMAND IS: 
* 
*     MUNLOCK-FBLOCK[,LBLOCK] 
* 
* FBLOCK AND LBLOCK SPECIFY THE FIRST AND LAST BLOCKS TO BE 
* MUNLOCKED. IF LBLOCK IS NOT SPECIFIED IT IS ASSUMED TO BE 
* EQUAL TO FBLOCK.
* 
      ORG LIBRA 
      JSB MUNNO     GET FIRST BLOCK 
      JMP MUN2      ILLEGAL FORMAT
      CPA .+54B     COMMA FOLLOWING?
      JMP MUN1      YES 
      CPA .+15B     NO, CR? 
      JMP MUN3      YES 
      JMP LFRER     NO, ERROR 
MUN1  EQU * 
      DLD MUNIN     SAVE FIRST
      DST MUNSB       BLOCK 
      JSB MUNNO     GET LAST BLOCK
      JMP MUN2      ILLEGAL FORMAT
      CPA .+15B     CR FOLLOWS? 
      RSS           YES 
      JMP LFRER     NO, ERROR 
      LDB MUNSB     COMPUTE 
      LDA MUNSB+1     LAST BLOCK -
      JSB MUNTS         FIRST BLOCK 
      SZB,RSS       DIFFERENCE VALID? 
      JMP MUN4      YES 
MUN2  EQU * 
      LDB .-19      NO, 
      JSB MUNER       ERROR 
      OCT 5111
      ASC 9,LLEGAL PARAMETERS 
MUN3  EQU * 
      DLD MUNIN     SAVE FIRST
      DST MUNSB       BLOCK 
      CLA           SET FOR ONE BLOCK 
MUN4  EQU * 
      INA           SAVE
      STA MUNLN       LENGTH
      LDA MHAD      => LAST WORD
      ADA .+48
      STA MUNTP       OF DISC EQT 
      JSB MUNDS     BLOCK TOO 
      SSB,RSS         LARGE?
      JMP MUN2      YES 
MUN5  EQU * 
      LDA MUNTP     NO, MOVE
      ADA .-6         TO NEXT DISC
      STA MUNTP         EQT ENTRY 
      JSB MUNDS     BLOCK ON
      SSB             THIS DISC?
      JMP MUN5      NO
      INA           YES, SAVE 
      STA MUNLA       LAST BLOCK
      DLD MUNSB     FIRST 
      DST MUNIN       BLOCK 
      JSB MUNDS         ON THIS 
      CLE,SSB             DISC ALSO?
      JMP MUN2      NO
      STA MUNFA     YES, SAVE IT
      ADA .-4       BLOCKS
      SEZ,RSS         0-3 ARE 
      JMP MUN2          ILLEGAL 
      LDA MUNTP     CHECK 
      ADA .+2         FOR 
      LDB A,I           DISC
      LDB B,I 
      SZB                 PRESENT 
      JMP MUN6      IT IS 
      LDB .-17      ERROR 
      JSB MUNER 
      OCT 5116
      ASC 8,ONEXISTENT DISC 
MUN6  EQU * 
      LDA M256      BAD BLOCKS IS 
      STA MWORD       256 WORDS LONG
      DLD MUNTP,I 
      CLE,ERA 
      ERB,CLE 
      ADB .+3       RESIDES ON BLOCK 3
      SEZ 
      INA 
      DST MUNSB 
      LDA MUNDA     READ
      LDB MUNBI       BAD BLOCKS
      JSB DISCZ,I       TABLE 
      JMP DDERR 
      JSB FADTP,I   GET THIS DISC ADT 
      LDA MUNAL,I   LENGTH
      STA MWORD       ADT 
      LDA MUNAD     READ
      LDB LIBDI       DISC
      JSB DISCZ,I       ADT 
      JMP DDERR 
      LDB L8192     => FIRST ENTRY
MUN10 EQU * 
      LDA B,I       GET ITEM
      SZA,RSS       FINISHED SEARCH?
      JMP MUN11     YES 
      CMA,CLE,INA   NO, IS
      ADA MUNFA       THIS ENTRY
      SZA,RSS           EQUAL?
      JMP MUN12     YES 
      SEZ,RSS       NO, GREATER 
      JMP MUN18     YES 
      ADB .+2       NO, FINISHED
      CPB MUNLZ       SEARCH? 
      RSS           YES 
      JMP MUN10     NO
MUN11 EQU * 
      JSB MUNPB     CHECK PRECEEDING BLOCK
      JMP MUN17     ENTRIES COMBINED
      JMP LEND      NO WORK DONE
MUN12 EQU * 
      INB           IS THIS 
      LDA MUNLN       ENTRY 
      CMA,CLE           COMPLETELY
      ADA B,I             ENCLOSED? 
      SEZ,RSS 
      JMP MUN13     YES 
      INA           NO, SAVE
      STA B,I         NEW LENGTH
      ADB .-1       SAVE NEW
      LDA MUNLA       STARTING
      STA B,I           ADDRESS 
      LDA MUNFA     ADDRESS OF BLOCK
      STA MUNRA       TO BE RETURNED
      LDA MUNLN     LENGTH OF RETURNED
      STA MUNRL       BLOCK 
      JSB MUNRS     RETURN BLOCK TO DISC ADT
      JMP MUN17 
MUN13 EQU * 
      LDA B,I       LENGTH AND
      STA MUNRL       ADDRESS OF
      ADB .-1           BLOCK TO
      LDA B,I             RETURN TO 
      STA MUNRA             DISC ADT
      STB MUNBR     SAVE (B)
      STB MUNPP     DESTINATION POINTER 
      ADB .+2       SOURCE POINTER
MUN14 EQU * 
      CPB MUNLZ 
      JMP MUN15 
      LDA B,I       ELIMINATE 
      SZA,RSS 
      JMP MUN15       COMPLETELY
      STA MUNPP,I 
      ISZ MUNPP         ENCLOSED
      INB 
      JMP MUN14           ENTRY 
MUN15 EQU * 
      CLA           ZERO OUT
      STA MUNPP,I     TWO WORDS 
      ISZ MUNPP         AFTER LAST
      STA MUNPP,I         ENTRY 
      LDB MUNBR     RESTORE (B)                    /
      JSB MUNRS     RETURN BLOCK TO DISC ADT
* 
* CHECK SUCCEEDING BLOCKS 
* 
MUN16 EQU * 
      LDA B,I       ANY MORE
      SZA,RSS         ENTRIES?
      JMP MUN17     NO
      LDA MUNLA     YES,
      CMA,CLE,INA     OVERLAP 
      ADA B,I           NEXT
      SEZ                 ENTRY?
      JMP MUN17     NO
      INB           YES,
      ADA B,I         COMPLETELY
      SZA,RSS           ENCLOSE IT? 
      JMP MUN13     YES 
      SEZ,RSS       MAYBE 
      JMP MUN13     YES 
      STA MUNPP     NO, SAVE LENGTH 
      CMA,INA       LENGTH OF 
      ADA B,I         RETURNED
      STA MUNRL         BLOCK 
      LDA MUNPP     SAVE LENGTH OF
      STA B,I         LOCKED BLOCK
      ADB .-1       ADDRESS OF
      LDA B,I         RETURNED
      STA MUNRA         BLOCK 
      LDA MUNLA     SAVE NEW
      STA B,I         STARTING BLOCK
      JSB MUNRS     RETURN SPACE TO DISC ADT
* WRITE DISC ADT AND LOCKED BLOCKS
* 
MUN17 EQU * 
      LDA M256      LENGTH OF 
      STA MWORD       BAD BLOCKS
      DLD MUNTP,I   COMPUTE 
      CLE,ERA 
      ERB,CLE       ADDRESS 
      ADB .+3 
      SEZ               OF BLOCK
      INA 
      DST MUNSB           THREE 
      LDA MUNDA     WRITE OUT 
      LDB L8192       LOCKED
      JSB DISCZ,I       BLOCKS
      JSB MDEDP,I 
      LDA MUNAL,I   WRITE 
      STA MWORD       OUT 
      LDA MUNAD         DISC
      LDB LIBD            ADT 
      JSB DISCZ,I           TRACK 
      RSS 
      JMP LEND
      CLA           DISC TROUBLE
      CLB 
      STA KILDF,I   MAKE ADT
      DST KILD,I      DISAPPEAR 
      JMP LEND
MUN18 EQU * 
      JSB MUNPB     CHECK PRECEEDING BLOCK
      JMP MUN16     GO CHECK
      JMP MUN16       NEXT ENTRY
* 
* MUNNO SCANS THE INPUT STRING FOR AN INTEGER LESS THAN 2**19. IF 
* FOUND IT RETURNS TO (P+2) WITH THE INTEGER IN MUNIN[0:1] AND
* THE FOLLOWING CHARACTER IN (A). ERRORS EXIT TO (P+1). 
* 
MUNNO NOP 
      CCB           SET FLAG FOR
      STB MUNTP       NUMBER OCCURRENCE 
      CLB           INITIALIZE
      STB MUNIN       TWO-DIGIT 
      STB MUNIN+1       RESULT
MUNN1 EQU * 
      JSB T35CQ     GET A CHARACTER 
      JMP MUNN2     CR
      LDB A 
      ADB M72B
      SSB,RSS       DIGIT!
      JMP MUNN2     NO
      ADB .+10      MAYBE 
      SSB 
      JMP MUNN2     NO
      STB MUNTP     YES, SAVE IT
      LDA MUNIN+1   GET PREVIOUS
      LDB MUNIN       RESULT
      ASL 2         MULTIPLY BY 4 
      CLE           ADD PREVIOUS
      ADA MUNIN+1     RESULT, 
      SEZ               PRODUCING 
      INB                 MULTIPLICATION
      ADB MUNIN            BY 5 
      ASL 1         NOW 10*PREVIOUS RESULT
      CLE           ADD IN
      ADA MUNTP 
      SEZ             NEW DIGIT 
      INB 
      STB MUNIN     SAVE NEW
      STA MUNIN+1     RESULT
      LDA B         TOO 
      AND .+7 
      CPA B           BIG?
      JMP MUNN1     NO
      JMP MUNNO,I   YES 
MUNN2 EQU * 
      ISZ MUNTP     DID NUMBER OCCUR? 
      ISZ MUNNO     YES 
      JMP MUNNO,I   NO
* 
* MUNTS SUBTRACTS THE TWO-WORD INTEGER INTEGER IN [(B),(A)] FROM MUNIN[0:1],
* LEAVING THE RESULT IN [(B),(A)].
* 
MUNTS NOP 
      CMA,CLE,INA   NEGATE
      CMB,SEZ 
      INB             SUBTRAHEND
      CLE 
      ADA MUNIN+1   ADD IN
      SEZ 
      INB             MINUEND 
      ADB MUNIN 
      JMP MUNTS,I 
* 
* MUNDS TAKES THE DISC ADDRESS IN MUNIN[0:1] AND COMPUTES IT
* RELATIVE TO THE DISC WHOSE EQT ENTRY IS POINTED TO BY MUNTP,
* EXITING WITH THE RESULT IN [(B),(A)]. 
* 
MUNDS NOP 
      DLD MUNTP,I   GET FIRST SECTOR NUMBER 
      CLE,ERA       CONVERT TO
      ERB             BLOCKS
      SWP 
      JSB MUNTS     COMPUTE RELATIVE ADDRESS
      JMP MUNDS,I 
* 
* MUNER OUTPUTS AN ERROR MESSAGE TO THE CONSOLE 
* 
MUNER NOP 
      STB MUNTP 
      LDA T35B1     MOVE
      STA MOVED       MESSAGE 
      LDA MUNER         INTO
      STA MOVES           CONSOLE 
      BRS                  BUFFER 
      JSB MOVEW 
      LDA MUNTP 
      CMA,INA 
      LDB T35B1 
      JMP LEND2     OUTPUT IT 
* 
* MUNPB CHECKS THE PRECEEDING BLOCK TO SEE IF THE NEW ENTRY IS IN 
* ITS RANGE. IF SO, IT MODIFIES THE PRECEEDING ENTRY, RETURNS THE 
* APPROPRIATE SPACE TO THE DISC ADT, AND EXITS TO (P+1),
* OTHERWISE TO (P+2). 
* 
MUNPB NOP 
      CPB L8192     BEGINNING OF TABLE? 
      JMP MUNP1 
      ADB .-1       NO, NEW 
      LDA B,I 
      STA MUNSB       BLOCK IN
      ADB .-1 
      ADA B,I           RANGE OF
      CMA,CLE 
      ADA MUNFA           PRECEEDING ONE? 
      SEZ,RSS 
      JMP MUNP2     YES 
      ADB .+2       NO
MUNP1 EQU * 
      ISZ MUNPB 
      JMP MUNPB,I 
MUNP2 EQU * 
      INA,SZA,RSS   ADJACENT? 
      JMP MUNP1-1   YES 
      CMA,INA       NO, SAVE LENGTH 
      STA MUNRL       OF RETURNED BLOCK 
      LDA MUNFA     ADDRESS OF
      STA MUNRA       RETURNED BLOCK
      LDA B,I       COMPUTE 
      CMA,INA         NEW 
      ADA MUNFA         LENGTH
      INB                 AND 
      STA B,I               SAVE
      ADB .-1       IS THE
      LDA MUNLA       UNLOCKED
      CMA,CLE           PORTION 
      ADA B,I             IN THE MIDDLE 
      ADA MUNSB             OF THE PREVIOUS 
      SEZ,INA,RSS             BLOCK?
      JMP MUNP6     NO
      STA MUNSB     YES 
      LDA MUNLN     RESET RETURNED
      STA MUNRL       BLOCK LENGTH
      ADB .+2       SAVE
      STB MUNBR       (B) 
      LDB MUNLY     TABLE 
      LDA B,I 
      SZA,RSS         FULL
      JMP MUNP3     NO
      LDB .-25      YES, OUTPUT 
      JSB MUNER       ERROR MESSAGE 
      OCT 5114
      ASC 12,OCKED BLOCKS TABLE FULL
MUNP3 EQU * 
      STB MUNPP     SOURCE POINTER
      ADB .-2       DESTINATION POINTER 
MUNP4 EQU * 
      LDA B,I       MAKE
      STA MUNPP,I 
      CPB MUNBR       ROOM
      JMP MUNP5 
      ADB .-1           FOR 
      CCA 
      ADA MUNPP           NEW 
      STA MUNPP 
      JMP MUNP4            ENTRY
MUNP5 EQU * 
      LDA MUNLA     SAVE ADDRESS
      STA B,I         OF NEW ENTRY
      INB           SAVE
      LDA MUNSB       LENGTH
      STA B,I           ALSO
      INB,RSS 
MUNP6 EQU * 
      ADB .+2 
      JSB MUNRS     RETURN SPACE TO DISC ADT
      JMP MUNPB,I 
* 
* MUNRS RETURNS SPACE TO THE DISC ADT TRACK WHICH IS CURRENTLY IN 
* CORE. 
* 
MUNRS NOP 
      STB MUNBR     SAVE (B)
      DLD MUNTP,I   COMPUTE 
      CLE,ERA 
      ERB,CLE         DISC
      ADB MUNRA 
      SEZ               ADDRESS 
      INA 
      DST MUNSB 
      JSB RBAD,I    RETURN SPACE
      LDB MUNBR     RESTORE (B) 
      JMP MUNRS,I 
* 
MUNPP EQU LTEMP 
MUNIN EQU LTEMP 
*                         LTEMP+1 
MUNLN EQU LTEMP+2 
MUNTP EQU LTEMP+3 
MUNFA EQU LTEMP+6 
MUNLA EQU LTEMP+7 
MUNRA EQU LTEMP+8 
MUNBR EQU LTEMP+9 
MUNAL EQU LTEMP+11
MUNAD EQU LTEMP+12
MUNRL EQU LTEMP+13
MUNSB EQU LTEMP+14
*                         LTEMP+15
* 
* LTEMP+4, LTEMP+5 AND LTEMP+10 ARE ALSO USED 
* 
MUNDA DEF MUNSB 
MUNBI DEF LIBUS+8192,I
MUNLZ DEF LIBUS+8192+256
MUNLY DEF LIBUS+8192+255
$MUN  EQU * 
