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.
* SLR R3,R3 ICM R3,B'0011',CCWREAD+6 LENGTH ATTEMPTED TO READ SLR R1,R1 ICM R1,B'0011',IORB+(IORCSW-IOR)+6 GET RESUDUAL LENGTH SR R3,R1 CALC ACTUAL BLOCK LENGTH * B LOADNUC LOAD NUCLES LOADMODULE
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.
LOADNUC DS 0H LA R4,INBUF POINT TO RECORD DATA * CLI TEXTSW,0 PROCESSING A TEXT RECORD? BNE TEXT YES - BRANCH * CLI 0(R4),X'01' CTL RECORD ? BE CTL * CLI 0(R4),X'05' CTL RECORD ? BE CTL * CLI 0(R4),X'0D' CTL RECORD ? BE CTL * CLI 0(R4),X'03' CTL+RLD RECORD ? BE CTL * CLI 0(R4),X'07' CTL+RLD RECORD ? BE CTL * CLI 0(R4),X'0F' CTL+RLD RECORD ? BE CTL * CLI 0(R4),X'02' RLD RECORD ? BE RLD * CLI 0(R4),X'06' RLD RECORD ? BE RLD * CLI 0(R4),X'0E' RLD RECORD ? BE RLD * B BREAD SKIP RECORD AND READ NEXT' *
We start by inspecting the first byte of the record to determine the type of record it is. We are only concerned with three types of records: Control (CTL), Relocation (RLD) and Text. It is possible a record may be both a Control and Relocation. A Text record follows a Control record and the first byte contains data not a record type. If the record type doesn’t indicate a Control or Relocation record then we can ignore it. We use TEXTSW as an indicator this record is a Text record.
CTL DS 0H MVI TEXTSW,1 NEXT RECORD IS A TEXT RECORD * SLR R1,R1 ZERO R1 ICM R1,B'0011',9(R4) GET LOAD ADDRESS ST R1,TEXTOFF SAVE OFFSET ICM R1,B'0111',13(R4) GET LENGTH ST R1,TEXTLEN SAVE LENGTH * TM 0(R4),X'02' RLD ALSO BO RLD YES - BRANCH * B BREAD GO READ NEXT RECORD *
In processing a Control record we start by setting TEXTSW to indicate the next record read will be a Text record. 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. We check to see if the Control record also contains Relocation data. If it does we can continue on to RLD else we read the next record.
TEXT DS 0H L R2,TEXTOFF GET TEXT OFFSET L R3,TEXTLEN GET TEXT LENGTH LR R5,R3 COPY LENGTH * R4 HAD TEXT RECORD ADDRESS MVCL R2,R4 COPY THE DATA * MVI TEXTSW,0 RESET TEXT SWITCH B BREAD PROCESS NEXT RECORD *
Processing of a Text record is straight forward. We recall the offset and the length of the data and use MVCL to copy it into place. We then reset TEXTSW to zero and read the next record.
RLD DS 0H B BREAD NOT RELOCATING NUCLEUS
Normally when loading a Load Module we have to deal with relocatable symbols. The load module is based off an address of zero and gets loaded into a higher address. We would use the RLD entries to add the load address to the value in the relocatable symbol. Sine we are loading the Nucleus at location zero our relocation offset is zero. This means we can ignore RLD data for loading the Nucleus. We simply loop back to read the next record.
BREAD030 DS 0H *+++++++ EOF READING DATA ++++++++ LPSW 0 LOAD NEW PSW * TO TRANSFER CONTROL TO NUCLEUS
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. The work of the IPL loader is complete.
The memory size, relocation to high memory, and Load Module loader are all implemented in DBOOT3. It can be run using the Absolute Loader.
DBOOT3 Source Code
[Next – DASD IPL Records]