KBCM     TITLE 'KERMBOOT - BOOTSTRAP FOR LOADING KERMIT-CMS'            00000010
*********************************************************************** 00000020
*    KERMBOOT VERSION 2 - J.F.CHANDLER, 1987 SEPTEMBER                * 00000030
*                                                                     * 00000040
*    KERMBOOT SHOULD BE GENMOD'ED AS A SMALL USER-AREA MODULE         * 00000050
*    NAMED 'KERMIT'.  IT WILL STEAL FREE STORAGE AND LOAD FROM        * 00000060
*    'KERMIT TEXT' INTO THAT AREA AND ALSO COPY A STUB FROM THE       * 00000070
*    BOOT ROUTINE.  THE STUB WILL CALL KERMIT AND, UPON RETURN,       * 00000080
*    RELEASE THE FREE STORAGE AND RETURN TO THE SYSTEM.               * 00000090
*                                                                     * 00000100
*  REGISTERS USED:                                                    * 00000110
*    3 =  SAVED FREELOWE ON ENTRY                                     * 00000120
*    4 =  FREELOWE SET AFTER LOADING                                  * 00000130
*    5 =  SAVED MAINHIGH                                              * 00000140
*    6 -> START OF STORAGE                                            * 00000150
*    7 =  SAVED SYSTEM RETURN ADR                                     * 00000160
*    8 -> START OF BOOT PROGRAM (X'20000')                            * 00000170
*    9 =  SAVED LOCCNT                                                * 00000180
*   10 =  SAVED REGISTER 1 ON ENTRY                                   * 00000190
*   12 =  START OF KERMIT PROGRAM                                     * 00000200
*   13 -> SYSTEM SAVE AREA                                            * 00000210
*********************************************************************** 00000220
         SPACE                                                          00000230
         PRINT NOGEN                                                    00000240
         NUCON                                                          00000250
         USING NUCON,0                                                  00000260
KERMBOOT START X'20000'                                                 00000270
         LR    8,15                                                     00000280
         USING KERMBOOT,8                                               00000290
         LR    10,1          SAVE REGS                                  00000300
         LR    7,14                                                     00000310
         XC    EPL,EPL       CLEAR PTR TO EXT. PLIST                    00000320
         CLM   10,8,=X'01'                                              00000330
         BL    NOEPL                                                    00000340
         CLM   10,8,=X'0B'                                              00000350
         BH    NOEPL                                                    00000360
         LR    1,0                                                      00000370
         MVC   EPL(16),0(1)  COPY EPL PTRS                              00000380
NOEPL    MVC   SVLBS,TXTLIBS SAVE LIBRARY NAMES                         00000390
         ICM   0,15,TXTDIRC  LOADED INTO MEMORY?                        00000400
         BNZ   SAVPTRS       YES, DON'T MESS WITH THEM                  00000410
         DMSKEY NUCLEUS                                                 00000420
         MVI   TXTLIBS,X'FF' CLEAR ALL NAMES                            00000430
         MVC   TXTLIBS+1(63),TXTLIBS                                    00000440
         DMSKEY RESET                                                   00000450
SAVPTRS  L     9,LOCCNT                                                 00000460
         L     5,MAINHIGH                                               00000470
         L     3,FREELOWE    SAVE THIS PTR FOR RESTORING                00000480
         LR    12,3          END OF STORAGE                             00000490
         S     12,EXTRA      ROOM FOR LOADER                            00000500
         S     12,KSIZ       LENGTH OF PROGRAM                          00000510
         LR    4,12          SAVE                                       00000520
         SH    4,=H'4096'                                               00000530
         CR    4,5           ROOM ENOUGH?                               00000540
         BL    NOSTOR        TOO BAD                                    00000550
         LR    6,4           SAVE START OF STUB                         00000560
         ICM   1,15,EPL      GET START OF COMMAND TEXT                  00000570
         BZ    NOEPLCOP      NONE                                       00000580
         LA    15,BLENGTH(6) START OF AREA FOR COMMAND TEXT             00000590
         MVC   0(256,15),0(1) COPY TEXT                                 00000600
         SR    15,1          GET OFFSET BETWEEN AREAS                   00000610
         LM    0,2,EPL                                                  00000620
         AR    0,15          APPLY OFFSET                               00000630
         AR    1,15                                                     00000640
         AR    2,15                                                     00000650
         STM   0,2,EPL                                                  00000660
NOEPLCOP ST    12,ORG        START OF KERMIT                            00000670
         UNPK  LOADORG(7),ORG+1(4)                                      00000680
         TR    LOADORG(6),HEXTAB                                        00000690
         MVI   LOADORG+6,C' '                                           00000700
*        WRTERM KNAME,LLOAD                                             00000710
         LA    1,LOAD                                                   00000720
         SVC   202           GET KERMIT INTO MEMORY                     00000730
         DC    AL4(LDRFAIL)                                             00000740
         STM   1,12,SAVREG   SAVE FOR CLEANUP                           00000750
         DMSKEY NUCLEUS                                                 00000760
         MVC   TXTLIBS(64),SVLBS RESTORE TXTLIB NAMES                   00000770
         ST    4,FREELOWE    USE THIS PTR FOR DURATION                  00000780
         ST    9,LOCCNT      RESET LOADER ADR TO ORIGINAL               00000790
         ST    5,MAINHIGH    RESET PROGRAM AREA LIMIT                   00000800
         ST    8,STRTADDR    RESET PROGRAM ENTRY POINT                  00000810
         DMSKEY RESET                                                   00000820
         MVC   0(BLENGTH,6),STUB  COPY CODE INTO STUB                   00000830
         LR    15,12         SET UP TO CALL PROGRAM                     00000840
         LR    1,10          RECOVER ORIGINAL PARM LIST                 00000850
         LA    0,EPL                                                    00000860
         BR    6             BRANCH INTO COPY OF STUB                   00000870
*                                                                       00000880
NOSTOR   LINEDIT TEXT='NOT ENOUGH FREE STORAGE',DOT=NO                  00000890
         LA    15,1          GIVE UP                                    00000900
         B     RETSYS                                                   00000910
*                                                                       00000920
LDRFAIL  DMSEXS MVC,TXTLIBS(64),SVLBS RESTORE TXTLIB NAMES              00000930
         B     RETSYS        AND RETURN WITH ERROR CODE                 00000940
*                                                                       00000950
*          CODE COPIED INTO FREE STORAGE                                00000960
         USING STUB,6                                                   00000970
         DS    0D                                                       00000980
STUB     BALR  14,15         CALL PROGRAM                               00000990
         USING *,14                                                     00001000
         LM    1,12,SAVREG   JUST IN CASE                               00001010
         DROP  14                                                       00001020
*                                                                       00001030
*   NOW WE OUGHT TO RE-LOAD THE BOOTSTRAP MODULE AND BRANCH BACK TO     00001040
*   IT, EXCEPT THAT WE ARE EXECUTING IN STOLEN STORAGE ANYWAY.          00001050
*   ALL THAT'S REALLY NEEDED IS TO RESET FREELOWE AND RETURN.           00001060
*                                                                       00001070
CLEANUP  C     4,FREELOWE    HOPE THIS IS BACK TO WHERE WE LEFT IT      00001080
         BNE   RETSYS                                                   00001090
         DMSEXS ST,3,FREELOWE    GOOD, DESTROY EVIDENCE                 00001100
RETSYS   LR    14,7                                                     00001110
         BR    14            RETURN TO SYSTEM                           00001120
SAVREG   DS    12F           SAVE AREA FOR STUB                         00001130
EPL      DS    4F            EXTENDED PARAMETER LIST                    00001140
         DS    0D                                                       00001150
BLENGTH  EQU   *-STUB                                                   00001160
*                                                                       00001170
SVLBS    DS    CL64          SAVED TXTLIB NAMES                         00001180
ORG      DS    F             SAVED START OF KERMIT                      00001190
KSIZ     DC    XL4'7000'     ROOM ALLOWED FOR KERMIT                    00001200
EXTRA    DC    XL4'3000'     EXTRA FOR SYSTEM                           00001210
LOAD     DC    CL8'LOAD'                                                00001220
KNAME    DC    CL8'KERMIT',CL8'(',CL8'ORIGIN'                           00001230
LOADORG  DC    CL8' '                                                   00001240
LLOAD    EQU   *-KNAME                                                  00001250
         DC    CL8'CLEAR',CL8'NOMAP',8X'FF'                             00001260
*                                                                       00001270
HEXTAB   EQU   *-240                                                    00001280
         DC    C'0123456789ABCDEF'                                      00001290
         END   KERMBOOT                                                 00001300
