{"id":291,"date":"2011-12-23T12:53:39","date_gmt":"2011-12-23T18:53:39","guid":{"rendered":"http:\/\/tommysprinkle.com\/txxos\/?p=291"},"modified":"2021-04-17T18:24:48","modified_gmt":"2021-04-17T23:24:48","slug":"nucleus-load-module-loader","status":"publish","type":"post","link":"https:\/\/tommysprinkle.com\/txxos\/?p=291","title":{"rendered":"Nucleus Load Module Loader"},"content":{"rendered":"<p>We have already developed code that can read the Volume Label, search the VTOC, locate a PDS directory member, and read the data associated with that member. Now we can write some code to load the contents of a load module into memory.<\/p>\n<pre>*\r\n         SLR   R3,R3\r\n         ICM   R3,B'0011',CCWREAD+6  LENGTH ATTEMPTED TO READ\r\n         SLR   R1,R1\r\n         ICM   R1,B'0011',IORB+(IORCSW-IOR)+6  GET RESUDUAL LENGTH\r\n         SR    R3,R1              CALC ACTUAL BLOCK LENGTH\r\n*\r\n         B     LOADNUC            LOAD NUCLES LOADMODULE<\/pre>\n<p>In our BREAD routine from DISK3 we will calculate the length of the record just read and place the length into Register 3 before branching to LOADNUC.<\/p>\n<pre>LOADNUC  DS    0H\r\n         LA    R4,INBUF           POINT TO RECORD DATA\r\n*\r\n         CLI   TEXTSW,0           PROCESSING A TEXT RECORD?\r\n         BNE   TEXT               YES - BRANCH\r\n*\r\n         CLI   0(R4),X'01'        CTL RECORD ?\r\n         BE    CTL\r\n*\r\n         CLI   0(R4),X'05'        CTL RECORD ?\r\n         BE    CTL\r\n*\r\n         CLI   0(R4),X'0D'        CTL RECORD ?\r\n         BE    CTL\r\n*\r\n         CLI   0(R4),X'03'        CTL+RLD RECORD ?\r\n         BE    CTL\r\n*\r\n         CLI   0(R4),X'07'        CTL+RLD RECORD ?\r\n         BE    CTL\r\n*\r\n         CLI   0(R4),X'0F'        CTL+RLD RECORD ?\r\n         BE    CTL\r\n*\r\n         CLI   0(R4),X'02'        RLD RECORD ?\r\n         BE    RLD\r\n*\r\n         CLI   0(R4),X'06'        RLD RECORD ?\r\n         BE    RLD\r\n*\r\n         CLI   0(R4),X'0E'        RLD RECORD ?\r\n         BE    RLD\r\n*\r\n         B     BREAD              SKIP RECORD AND READ NEXT'\r\n*<\/pre>\n<p>We start by inspecting the first byte of the record to determine the type of record it is.\u00a0 We are only concerned with three types of records: Control (CTL), Relocation (RLD) and Text.\u00a0 It is possible a record may be both a Control and Relocation.\u00a0 A Text record follows a Control record and the first byte contains data not a record type.\u00a0 If the record type doesn&#8217;t indicate a Control or Relocation record then we can ignore it.\u00a0 We use TEXTSW as an indicator this record is a Text record.<\/p>\n<pre>CTL      DS    0H\r\n         MVI   TEXTSW,1           NEXT RECORD IS A TEXT RECORD\r\n*\r\n         SLR   R1,R1              ZERO R1\r\n         ICM   R1,B'0011',9(R4)   GET LOAD ADDRESS\r\n         ST    R1,TEXTOFF         SAVE OFFSET\r\n         ICM   R1,B'0111',13(R4)  GET LENGTH\r\n         ST    R1,TEXTLEN         SAVE LENGTH\r\n*\r\n         TM    0(R4),X'02'        RLD ALSO\r\n         BO    RLD                YES - BRANCH\r\n*\r\n         B     BREAD              GO READ NEXT RECORD\r\n*<\/pre>\n<p>In processing a Control record we start by setting TEXTSW to indicate the next record read will be a Text record.\u00a0 We then get the address the data is to be loaded at and save it in TEXTOFF and the length of the data which is saved in TEXTLEN.\u00a0 We check to see if the Control record also contains Relocation data.\u00a0 If it does we can continue on to RLD else we read the next record.<\/p>\n<pre>TEXT     DS    0H\r\n         L     R2,TEXTOFF         GET TEXT OFFSET\r\n         L     R3,TEXTLEN         GET TEXT LENGTH\r\n         LR    R5,R3              COPY LENGTH\r\n*                                 R4 HAD TEXT RECORD ADDRESS\r\n         MVCL  R2,R4              COPY THE DATA\r\n*\r\n         MVI   TEXTSW,0           RESET TEXT SWITCH\r\n         B     BREAD              PROCESS NEXT RECORD\r\n*<\/pre>\n<p>Processing of a Text record is straight forward.\u00a0 We recall the offset and the length of the data and use MVCL to copy it into place.\u00a0 We then reset TEXTSW to zero and read the next record.<\/p>\n<pre>RLD      DS    0H\r\n         B     BREAD              NOT RELOCATING NUCLEUS<\/pre>\n<p>Normally when loading a Load Module we have to deal with relocatable symbols.\u00a0 The load module is based off an address of zero and gets loaded into a higher address.\u00a0 We would use the RLD entries to add the load address to the value in the relocatable symbol.\u00a0 Sine we are loading the Nucleus at location zero our relocation offset is zero.\u00a0 This means we can ignore RLD data for loading the Nucleus.\u00a0 We simply loop back to read the next record.<\/p>\n<pre>BREAD030 DS    0H\r\n*+++++++ EOF READING DATA ++++++++\r\n         LPSW  0                  LOAD NEW PSW\r\n*                                     TO TRANSFER CONTROL TO NUCLEUS<\/pre>\n<p>When we get an End of File condition we transfer control to the newly loaded Nucleus by executing a LPSW to load a new PSW from location zero.\u00a0 The work of the IPL loader is complete.<\/p>\n<p>The memory size, relocation to high memory, and Load Module loader are all implemented in DBOOT3. \u00a0It can be run using the Absolute Loader.<\/p>\n<p>DBOOT3 Source Code<\/p>\n<p>[Next &#8211; <a title=\"DASD IPL Records\" href=\"http:\/\/tommysprinkle.com\/txxos\/?p=299\">DASD IPL Records<\/a>]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have already developed code that can read the Volume Label, search the VTOC, locate a PDS directory member, and read the data associated with that member. Now we can write some code to load the contents of a load &hellip; <a href=\"https:\/\/tommysprinkle.com\/txxos\/?p=291\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"template-page-builder-no-sidebar.php","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1CPQT-4H","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291"}],"version-history":[{"count":4,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":492,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=\/wp\/v2\/posts\/291\/revisions\/492"}],"wp:attachment":[{"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tommysprinkle.com\/txxos\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}