         << LINES .001/.009 ARE RESERVED FOR SYSTEMS INTEGRATION >>     00000001
$PAGE "INCLPARL -- Put on ARL"                                          00010000
PROCEDURE PUTONARL(ADDRESS,SIZE,HEADOFLIST);                            00015000
VALUE ADDRESS,SIZE,HEADOFLIST;                                          00020000
DOUBLE ADDRESS;                                                         00025000
INTEGER SIZE;                                                           00030000
LOGICAL HEADOFLIST;                                                     00035000
OPTION PRIVILEGED,UNCALLABLE;                                           00040000
                                                                        00045000
COMMENT                                                                 00050000
                                                                        00055000
PUTONARL is called by RELEASEREGION, RESERVEREGION, and COLLECT         00060000
GARBAGE to place the region whose base address is given by              00065000
the address parameter at the head or tail of the list of                00070000
available regions.                                                      00075000
                                                                        00080000
DB is assumed to be at SYSDB when called.                               00085000
                                                                        00090000
The condition code is not modified.                                     00095000
                                                                        00100000
;                                                                       00105000
                                                                        00110000
   BEGIN                                                                00115000
                                                                        00120000
   DOUBLE OLDLISTHEAD,                                                  00125000
          OLDLISTTAIL,                                                  00130000
      PREVLINK,                                                         00135000
      NEXTLINK;                                                         00140000
                                                                        00145000
SUBROUTINE PLACEATHEAD;                                                 00150000
                                                                        00155000
   BEGIN                                                                00160000
   OLDLISTHEAD := HOLELISTHEAD;                                         00165000
   TOS := ADDRESS;                                                      00170000
   TOS := TOS + RBTONLDISP;                                             00175000
   HOLELISTHEAD := TOS;                                                 00180000
   TOS := ADDRESS;                                                      00185000
   TOS := TOS+RBTOPLDISP;                                               00190000
   TOS := 0D;                                                           00195000
   ASMB(SDEA);      << zero out prev link >>                            00200000
   TOS := TOS+PLTONLDISP;                                               00205000
   TOS := OLDLISTHEAD;                                                  00210000
   ASMB(SDEA;DDEL);                                                     00215000
   IF OLDLISTHEAD <> 0D THEN                                            00220000
      BEGIN       << must update prevlink of old head. >>               00225000
      TOS := OLDLISTHEAD;                                               00230000
      TOS := TOS+NLTOPLDISP;                                            00235000
      TOS := ADDRESS;                                                   00240000
      TOS := TOS + RBTOPLDISP;                                          00245000
      ASMB(SDEA;DDEL);                                                  00250000
      END;                                                              00255000
   END;     << subroutine PLACEATHEAD >>                                00260000
                                                                        00265000
SUBROUTINE PLACEATTAIL;                                                 00270000
                                                                        00275000
   BEGIN                                                                00280000
                                                                        00285000
   OLDLISTTAIL := HOLELISTTAIL;                                         00290000
   TOS := ADDRESS;                                                      00295000
   TOS := TOS + RBTONLDISP;                                             00300000
   HOLELISTTAIL := TOS;                                                 00305000
   MAXAVAILREG := SIZE;                                                 00310000
                                                                        00315000
<< Fill in prev and next links of this hole. >>                         00320000
                                                                        00325000
   TOS := ADDRESS;                                                      00330000
   TOS := TOS+RBTONLDISP;                                               00335000
   TOS := 0D;                                                           00340000
   ASMB(SDEA);         << zero out Next link >>                         00345000
   IF OLDLISTTAIL <> 0D THEN                                            00350000
      BEGIN                                                             00355000
      TOS := TOS+NLTOPLDISP;                                            00360000
      TOS := OLDLISTTAIL;                                               00365000
      TOS := TOS + NLTOPLDISP;                                          00370000
      ASMB(SDEA);    << update Prev in list ptr >>                      00375000
      END;                                                              00380000
   DDEL;                                                                00385000
                                                                        00390000
<< Update old tail's Next link >>                                       00395000
                                                                        00400000
   TOS := OLDLISTTAIL;                                                  00405000
   IF = THEN ASMB(DDEL) ELSE                                            00410000
      BEGIN                                                             00415000
      TOS := ADDRESS;                                                   00420000
      TOS := TOS+RBTONLDISP;                                            00425000
      ASMB(SDEA;DDEL);                                                  00430000
      END;                                                              00435000
   END;      << subroutine PLACEATTHEAD >>                              00440000
                                                                        00445000
                                                                        00450000
   IF LOGICAL(SIZE) > LOGICAL(MAXHOLESIZE) THEN ASMB(HALT 3);           00455000
                                                                        00460000
   HOLECOUNT := HOLECOUNT+1;                                            00465000
                                                                        00470000
   IF HOLELISTHEAD = 0D THEN                                            00475000
      BEGIN       << List of holes is empty. >>                         00480000
      PLACEATHEAD;                                                      00485000
      PLACEATTAIL;                                                      00490000
      END                                                               00495000
   ELSE IF size >= maxavailreg AND NOT headoflist              <<*7543>>00500000
   THEN PLACEATTAIL ELSE                                                00505000
      BEGIN     << Must merge into list >>                              00510000
                                                                        00515000
<< Locate position in the hole list for this hole. >>                   00520000
                                                                        00525000
      TOS := NLTORSDISP;<<Offset from Link to target for LLSH>>         00530000
      IF HEADOFLIST THEN TOS := SIZE ELSE TOS := SIZE+1;                00535000
      TOS := HOLELISTHEAD;    << first link addr for LLSH >>            00540000
      X := HOLECOUNT-1;       << link count >>                          00545000
      ASMB(LLSH);<<Chase thru the list to get to right place >>         00550000
      IF > THEN ASMB(HALT 3) ELSE IF < THEN PLACEATTAIL ELSE            00555000
         BEGIN    << got a hit >>                                       00560000
         IF NOT HEADOFLIST THEN                                         00565000
            BEGIN    << Put in front of link on TOS >>                  00570000
            TOS := TOS+NLTOPLDISP;                                      00575000
            ASMB(LDEA);                                                 00580000
            PREVLINK := TOS;                                            00585000
            END                                                         00590000
         ELSE                                                           00595000
            BEGIN    << Goes after addr on TOS >>                       00600000
            TOS := TOS+NLTOPLDISP;                                      00605000
            PREVLINK := TOS;                                            00610000
            END;                                                        00615000
                                                                        00620000
<< Now link in behind previous region base. >>                          00625000
                                                                        00630000
         TOS := PREVLINK;                                               00635000
         IF = THEN PLACEATHEAD ELSE                                     00640000
            BEGIN                                                       00645000
            TOS := TOS+PLTONLDISP;                                      00650000
            ASMB(LDEA);                                                 00655000
            NEXTLINK := TOS;                                            00660000
            TOS := ADDRESS;                                             00665000
            TOS := TOS+RBTONLDISP;                                      00670000
            ASMB(SDEA); << Put new next link in prev in list >>         00675000
                                                                        00680000
            TOS := NEXTLINK;                                            00685000
            IF = THEN ASMB(HALT 3); <<End of list case taken >>         00690000
            TOS := TOS+NLTOPLDISP;                                      00695000
            TOS := ADDRESS;                                             00700000
            TOS := TOS + RBTOPLDISP;                                    00705000
            ASMB(SDEA);  << put new prev ptr in next in list >>         00710000
                                                                        00715000
            TOS := ADDRESS;                                             00720000
            TOS := TOS+RBTONLDISP;                                      00725000
            TOS := NEXTLINK;                                            00730000
            ASMB(SDEA);   << put next link into this region >>          00735000
            TOS := TOS+NLTOPLDISP;                                      00740000
            TOS := PREVLINK;                                            00745000
            ASMB(SDEA); << Put Prev reg. ptr into this reg.  >>         00750000
            END;                                                        00755000
         END;                                                           00760000
      END;                                                              00765000
   END;    << procedure PUTONARL>>                                      00770000
$TITLE " "                                                              00775000
