
      HED GET 
* THE GET ROUTINE IS RESPONSIBLE FOR LOADING A PROGRAM FROM THE 
* USER LIBRARY. IT CAN BE USED TO LOAD FROM EITHER THE USER'S 
* PRIVATE LIBRARY, THE GROUP LIBRARY, OR THE PUBLIC LIBRARY.
* IF THE PROGRAM IS TO BE FROM THE USER'S GROUP LIBRARY, THE
* PROGRAM NAME SHOULD BE PRECEDED BY A SNOMFLAKE (*).  IF IT IS TO
* BE FROM THE PUBLIC LIBRARY, THE PROGRAM NAME SHOULD BE PRECEDED 
* BY A DOLLAR SIGN ($). 
      SPC 1 
      ORG LIBRA 
      SPC 1 
      LDA MLINK+1   GET USER'S ID.
      ADA .+?ID-?LINK 
      STA GETI
      LDA 0,I 
      STA LTEMP     STORE IN LTEMP. 
      LDA DLTEM     SET UP POINTER FOR NAME.
      INA 
      STA GETP
      LDA .-3       SET UP COUNTER. 
      STA GETC
      JSB LCHAR     GET FIRST INPUT CHAR. 
      JMP GET1      ERROR IF NONE.
      CPA .+44B     IF $ GO TO SET UP FOR 
      JMP GET2       SEARCHING PUBLIC LIBRARY.
      CPA .+52B     IF * GO TO SET UP FOR 
      JMP GET14       SEARCHING GROUP LIBRARY 
GET3  ALF,ALF       SAVE CHARACTER IN TABLE.
      STA GETP,I
      JSB LCHAR     GET RIGHT CHARACTER.
      LDA .+40B     IF END CHANGE TO BLANK. 
      IOR GETP,I
      STA GETP,I
      ISZ GETP      BUMP POINTER. 
      JSB LCHAR     GET NEXT CHARACTER. 
      LDA .+40B 
      ISZ GETC      DO WE WANT IT?
      JMP GET3      YES.
      CPA .+40B     NO--A SHOULD NOW BE BLANK.
      JMP GET4
* 
GET1  LDA .-13
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5111
      ASC 6,NVALID NAME 
* 
* PUBLIC LIBRARY PROGRAM
* 
GET2  LDA A000      SET UP FOR PUBLIC LIBRARY SEARCH
      STA LTEMP 
      JSB LCHAR     GET FIRST CHAR OF NAME. 
      JMP GET1      FAIL IF NONE. 
      JMP GET3
* 
* GROUP LIBRARY PROGRAM 
* 
GET14 LDA LTEMP     GET USER'S ID 
      AND B1777     ISOLATE NUMERICAL PART
      CLB 
      DIV .100      DIVIDE BY 100 AND 
      MPY .100        MULTIPLY BACK, DROPPING REMAIN
      LDB A         SAVE RESULTING MULTIPLE OF 100
      LDA M2000     GET UPPER 6 BITS MASK 
      AND LTEMP     GET ALPHABETIC PART OF ID 
      IOR B         MERGE NEW NUMERICAL PART
      STA LTEMP     STORE LIBRARIAN ID
      JSB LCHAR     GET FIRST CHAR OF NAME
      JMP GET1      FAIL IF NONE
      JMP GET3      ELSE, CONTINUE
* 
* AT THIS POINT THE ID OF THE LIBRARY CONTAINING THE DESIRED PROGRAM
*   IS IN LTEMP AND THE PROGRAM NAME IS IN LTEMP+1, LTEMP+2, AND
*   LTEMP+3 
* 
GET4  JSB RDPRG 
      LDA SPROG     SAVE END-OF-
      STA GETS        COMMON POINTER
      JSB DLOKP,I   SEARCH DIRECTORY FOR PROGRAM
      JMP GET18 
* 
GET19 LDA .-16
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5116
      ASC 7,O SUCH PROGRAM
GET22 LDA .-19
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5111
      ASC 9,LL-STORED PROGRAM 
* 
* THE PROPER DIRECTORY TRACK IS NOW IN CORE WITH GETPD POINTING TO
*   THE PROGRAM ENTRY 
* 
GET18 LDB GETPD     CHECK ILL-STORED
      ADB .+4         PROGRAM FLAG
      LDA B,I 
      SSA,RSS       UNSUCCESSFULLY STORED?
      JMP GET9      NO, CONTINUE
      LDA GETI,I    YES, GET USER'S ID
      CPA LTEMP     DOES HE (OR SHE) OWN THE PROG?
      JMP GET22     YES, PRINT ILL-STORED PROGRAM 
      JMP GET19     NO, PRINT NO SUCH PROGRAM 
GET9  ADB .-2       TEST FOR FILE 
      LDA 1,I 
      ADB .+6       => DISC ADDRESS 
      SSA,RSS       SKIP IF FILE
      JMP GET15 
* 
      LDA .-16
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5105      LF-E
      ASC 7,NTRY IS A FILE
* 
* FOUND CORRECT ENTRY.  CHECK TO SEE IF THE PROGRAM FITS
* 
GET15 ADB .-7       => FIRST WORD OF NAME 
      LDA B,I       MOVE WITH PROTECTED FLAG
      STA LTEMP+1     TO SAFE PLACE 
      ADB .+2       => THIRD WORD OF NAME 
      LDA 1,I       SAVE SEMI-
      STA LIBSC       COMPILED FLAG 
      INB           RETRIEVE START- 
      LDA 1,I         OF-PROGRAM
      ELA,CLE,ERA 
      STA LIBSP         POINTER 
      ADB .+7       GET PROGRAM 
      LDA 1,I         LENGTH. 
      STA GETLN 
      CMA,INA       COMPUTE FIRST 
      ADA LIBSP       UNUSED WORD 
      STA LIBPB 
      CMA,INA       COMPUTE NEGATIVE
      LDB LIBSC 
      SSB,RSS       SEMI-COMPILED?
      JMP GET25     NO
      ADA LWAUS 
      SSA,RSS       TOO BIG?
      JMP GET13     NO
      JMP GET26     YES 
GET25 EQU * 
      ADA LW97      TOTAL LENGTH
      SSA,RSS       COMPARE WITH MAX ALLOWED. 
* 
      JMP GET13     OK
GET26 EQU * 
      LDA .-18
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5120      LF-P
      ASC 8,ROGRAM TOO LARGE
* 
* EVERYTHING CHECKS, GO GET THE PROGRAM 
* 
GET13 JSB DATE      SET NEW DATE
      LDB GETPD      INTO 
      ADB .+5       DIRECTORY.
      STA 1,I 
      ADB .+3       GET PROGRAM 
      DLD B,I         DISC
      DST GETDI         ADDRESS 
* 
      LDA GETP,I    WRITE DIRECTORY 
      STA MWORD       BACK TO 
      LDA GETP          DISC
      ADA .+5 
      LDB LIBD
      JSB DISCZ,I 
      JSB SICKP,I   MUY MALO! 
* 
* 
      LDB MLINK+1   SET TO NULL PROGRAM 
      ADB .+?PROG-?LINK 
      LDA B,I       SAVE PROGRAM
      STA GETC        LENGTH
      LDA GETS
      STA 1,I 
      JSB RDPRG     READ IN CURRENT USER PROGRAM. 
      LDB GETLN     GET WORD COUNT
      STB MWORD     STORE WORD COUNT
      LDB LIBSP     GET START OF PROGRAM POINTER
      ADB BIT15       AND READ BIT
      LDA GETDP     GET PTR TO DISK ADDRESS 
      JSB DISCZ,I 
      RSS 
      JMP GET17 
      LDB MLINK+1 
      ADB .-?LINK 
      STB MAIN
      ADB .+?PROG 
      LDA GETC
      STA B,I 
      JSB RDPRG 
      LDA M32 
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5125      LF-U
      ASC 15,NABLE TO RETRIEVE FROM LIBRARY 
* 
* THE PROGRAM IS NOW IN CORE.  WRAP THINGS UP.
* 
GET17 LDA GETI,I    GET USER'S ID 
      ISZ GETI      FIRST WORD OF NAME. 
      LDB LTEMP+1   GET IT
      CPA LTEMP     IF PROGRAM OWNER CLEAR
      ELB,CLE,ERB    RUN-ONLY BIT.
      STB GETI,I    STORE FIRST WORD OF NAME. 
      ISZ GETI      BUMP POINTER TO NEXT WORD.
      DLD LTEMP+2   GET LAST 2 WORDS OF NAME. 
      DST GETI,I    STORE IN TABLE. 
      JSB SEMIC 
      JMP LLEND     TERMINATE.
GETDP DEF GETDI     => DISK ADDRESS 
* 
GETP  EQU LTEMP+4   => DIREC ENTRY
GETPD EQU LTEMP+5   => DIRECTORY ENTRY
GETI  EQU LTEMP+6   USER ID 
GETC  EQU LTEMP+7   COUNTER 
GETLN EQU LTEMP+10  PROGRAM LENGTH
GETS  EQU LTEMP+11  => START-OF-PROGRAM 
GETDI EQU LTEMP+14  DISC
*                         LTEMP+15    ADDRESS 
* 
* LTEMP, LTEMP+1, LTEMP+2, LTEMP+3, LTEMP+8 & LTEMP+9 ARE ALSO USED 
* 
$GET  EQU * 
      HED APPEND
* THE APPEND COMMAND ALLOWS A USER TO APPEND A LIBRARY PROGRAM ON TO
* THE END OF HIS CURRENT PROGRAM. THE FIRST STATEMENT OF THE NEW
* PROGRAM MUST HAVE A SEQUNCE NUMBER GREATER THAN THAT OF THELAST 
* STATEMENT OF THE ORIGINAL PROGRAM. IF THE NEW SECTION IS PROTECTED
* THE ENTIRE PROGRAM WILL BE PROTECTED. SEMI-COMPILED PROGRAMS AND
* PROGRAMS WITH COMMON MAY NOT BE APPENDED
* 
* THE CODE FOR APPEND MUST FOLLOW THE CODE FOR "GET". 
      SPC 1 
      ORG LIBRA     THE CODE IS IDENTICAL TO "GET"
      LDA MLINK+1   UP TO LOCATION GET15
      ORG GET15 
* 
* THE PROPER DIRECTORY ENTRY IS NOW IN CORE AND IS POINTED TO BY
*   GETPD.
* 
      ADB .-5       => THIRD WORD OF NAME 
      LDA 1,I 
      SSA,RSS       SEMI-COMPILED?
      JMP APP01     NO
* 
      LDA .-22
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5123      LF-S
      ASC 10,EMI-COMPILED PROGRAM 
* 
* THE PROGRAM TO BE APPENDED IS NOT SEMI-COMPILED 
* 
APP01 INB 
      LDA 1,I 
      CPA PBUFF     COMMON AREA?
      JMP APP02     NO
* 
      LDA .-23
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5116      LF-N
      ASC 11,O COMMON AREA ALLOWED
* 
* NOR DOES IT CONTAIN ANY COMMON STATEMENTS 
* 
APP02 JSB DATE      SET DATE OF LAST REFERENCE
      LDB GETPD      INTO DIRECTORY ENTRY.
      ADB .+5 
      STA 1,I 
      ADB .-4       SAVE 'PROTECTED' BIT
      LDA 1,I 
      STA APPLS 
      ADB .+7       GET PROGRAM 
      DLD B,I         DISC
      DST GETDI         ADDRESS 
      LDB GETPD           AND 
      ADB .+11
      LDA B,I               PROGRAM 
      STA GETLN               LENGTH
* 
* RETURN UPDATED DIRECTORY TO DISC
* 
      LDA GETP,I    WRITE DIRECTORY 
      STA MWORD       BACK TO DISC
      LDA GETP
      ADA .+5 
      LDB LIBD
      JSB DISCZ,I 
      JSB SLVAG,I   BLEW IT, TRY TO SALVAGE 
* 
      JSB RDPRG     READ IN USER'S PROGRAM AND
      JSB DCMPL      DECOMPILE IT.
      CLA           CLEAR ERROR FLAG             [B]
      STA OFLAG                                  [B]
* 
* CHECK IF COMBINED PROGRAMS WILL FIT IN CORE 
* 
      LDA GETLN     TEST FOR PROGRAM TOO
      CMA,INA        LARGE. 
      ADA PBPTR     LAST WORD+1 OF COMBINED PROGS.
      STA LIBPB 
      CMA,INA       COMPUTE NEGATIVE
      ADA LW97      TOTAL LENGTH
      SSA,RSS       COMPARE WITH MAX ALLOWED. 
      JMP APP1      O.K.
* 
      LDA MLINK+1   SET MAIN TO SAY PROGRAM IN
      ADA .-?LINK    CORE.
      STA MAIN
      LDA .-18
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5120      LF-P
      ASC 8,ROGRAM TOO LARGE
* 
* EVERYTHING IS FINE.  GO GET THE PROGRAM 
* 
APP1  LDB GETLN     GET LENGTH OF PROGRAM TO BE APPD
      STB MWORD     STORE WORD COUNT
      LDB PBPTR     INITIATE
      ADB BIT15 
      LDA APPDP       DISK
      JSB DISCZ,I       READ
      JMP APP9      UNABLE TO READ PROGRAM
* 
* SCAN ORIGINAL PROGRAM TO DETERMINE LAST SEQUENCE NUMBER.
* 
      LDA SPROG     A => LENGTH OF
      INA            FIRST STATEMENT. 
      LDB PBPTR     SET B TO POINT AT LENGTH OF 
      INB            FIRST NEW PROGRAM. 
      CPA 1         IF EQUAL, PROGRAM IS NULL, SO 
      JMP APP2       IT'S OK. 
      CMA,INA 
      ADA B 
      SSA,RSS       IS SPROG>PBPTR? 
      JMP APP5-2    NO
      LDA PBPTR     YES, RESET SPROG
      STA SPROG 
      JMP APP2
* 
      LDA SPROG     RESTORE 
      INA             (A) 
APP5  STA APPS      SAVE LOCN OF THIS STATE. LENGTH.
      ADA 0,I       LINK TO NEXT ONE. 
      CPA 1         IF SAVE AS B, APPS=>LAST STATE. 
      RSS 
      JMP APP5      OTHERWISE, LOOP.
* 
      CCA           GET SEQUENCE # OF LAST STATE- 
      ADA APPS       MENT.
      LDA 0,I       MAKE NEGATIVE AND SUBTRACT
      CMA,RSS        ONE. 
APP2  CCA           SET TO -1 (SEQNO=0) IF NO PROG. 
* 
* SEQUENCE NUMBER CHECK 
* 
      ADA PBPTR,I   CHECK THAT FIRST SEQUENCE # IS
      SSA,RSS        GREATER THAN LAST ONE OF OLD 
      JMP APP3        PROGRAM.
* 
      LDA MLINK+1   SET MAIN TO SAY PROGRAM IN
      ADA .-?LINK    CORE.
      STA MAIN
      LDA .-24      ERROR.
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5123      LF-S
      ASC 11,EQUENCE NUMBER OVERLAP 
* 
APP9  LDA MLINK+1 
      ADA .-?LINK 
      STA MAIN
      LDA M32 
      LDB *+2 
      JMP LIBER 
      DEF *+1 
      OCT 5125      LF-U
      ASC 15,NABLE TO RETRIEVE FROM LIBRARY 
* 
* THE APPENTANT IS IN PLACE.  WRAP THINGS UP. 
* 
APP3  LDA LIBPB     SET NEW VALUE OF
      STA PBPTR      PBPTR. 
      LDB MLINK+1 
      ADB .+?FLAG-?LINK 
      LDA PUALT 
      CMA           CLEAR PROGRAM 
      AND B,I         UNALTERED BIT 
      STA B,I 
      ADB .+?ID-?FLAG 
      LDA B,I       GET USER ID 
      INB           SET POINTER TO NAME.
      CPA LTEMP     TEST FOR SPECIAL
      JMP APP6       USER.
      LDA APPLS     IF NOT, GET 'PROTECTED' BIT 
      AND BIT15      AND MERGE INTO NAME. 
      IOR 1,I 
      STA 1,I 
APP6 ADB  .-?NAME   SET MAIN. 
      STB MAIN
      JMP LLEND     TERMINATE.
APPDP DEF GETDI     => DISC ADDRESS 
* 
APPLS EQU LTEMP+6   'PROTECTED' BIT STORAGE 
APPS  EQU LTEMP+7   STATEMENT POINTER 
* 
* LTEMP, LTEMP+1, LTEMP+2, LTEMP+3, LTEMP+4, LTEMP+5, LTEMP+10, 
*   LTEMP+11, LTEMP+13, LTEMP+14, AND LTEMP+15 ARE ALSO USED
* 
$APP  EQU * 
