1CSCI 468   Spring, 2007     LOADER - Lite    R.P. Rannie Page  1 of 4

Object Module Record Types ==================================

ESD = External Symbol Dictionary
TXT = Text
RLD = Relocation Dictionary
END = End

Overview ========================================================

The SVC 8 module used in Student Operating System (SOS) assignments
requires only a subset of full blown LOADER functions.  Hence the
name: 'LOADER - Lite'.  LOADER - Lite (LL) will process only a
single ESD record, and that record will contain only a single, 16
byte, ESD field.  All RLD records will be ignored.  This means that
all Object Modules to be loaded by 'LOADER - Lite' may not contain
A-Cons (or V-Cons).  Note that this includes the 'LOADER - Lite' routine
itself.

All operations in programs (Object Modules) to be loaded must replace DC statements using Address Constants (A-Cons) with executable LA and ST instructions.  The single exception to this requirement would be to have an OM containing A-Cons which was assembled with a START (rather than a CSECT) instruction, in which the address of the START was the same as the address to which the OM was to be loaded.

You will write an SVC 8 (defining SVC8 as your CSECT name).  However, you will begin SVC8 with a START at address X'20000'.  You will assemble using HLASMC to create an OM as a member (SVC8) in a temporary Partitioned Data Set (PDS) named &&O (that's capital letter O).  This data set will be passed to subsequent steps of a multistep job.  The JCL for this step will be:

 //STEP1 EXEC HLASMC,   CPARM= NEEDS TO START IN COLUMN 16 ON A 
 //*                    FOLLOWING // CARD.  THE NEEDED CPARMS ARE
 //*                    LISTED, BUT YOU WILL NEED TO GO THROUGH 
 //*                    COLUMN 71, PUT A '/' IN COLUMN 72, AND 
 //*                    CONTINUE THE PARMS, RESUMING IN COLUMN 16 ON
 //*                    A FOLLOWING // CARD.  NEEDED PARMS FOLLOW:
 //* 'NORLD,NOESD,NORXREF,USING(NOMAP),NOMXREF,LIST,NODXREF,NOXREF' 
 //*  IF PROBLEMS OCCUR WITH YOUR HLASMC, REMOVE THESE CPARMS!
 //*ASM.SYSLIB DD
 //*           DD
 //*           DD DSN=T90RPR1.CS468PUB.MACLIB,DISP=SHR ASK IF NEEDED
 //*              YOU SHOULD NOT NEED ADDITIONAL SYSLIB!
 //ASM.SYSLIN DD DSN=&&O(SVC8),SPACE=(6160,(1,1,1)),  NO X IN COL 72
 //*456789A123456                        CARD COLUMNS
 //             DCB=(LRECL=80,RECFM=FB) 'DCB' =MUST= BEGIN IN COL 16
 //ASM.SYSIN DD *
         Your SVC8   CSECT   through   END   SVC8  goes here.
 /*

Step Two.  The second step of your job will be to execute IEBCOPY
in order to create a copy of &&O(SVC8) that will be named
&&OO(SVC8).  (Only one copy of a data set with a given temporary
name may occur in any one step.)  The JCL for STEP2 will be:

 //STEP2 EXEC PGM=IEBCOPY
 //SYSPRINT DD SYSOUT=*
 //OLD DD DSN=&&O,DISP=(OLD,PASS)
 //NEW DD DSN=&&OO,DISP=(NEW,PASS),SPACE=(6160,(1,1,1))
 //SYSIN DD *
     COPY INDD=OLD,OUTDD=NEW
 /*

1CSCI 468   Spring, 2007   LOADER - Lite    R.P. Rannie Page  2 of 4

STEP1 and STEP2 are required before your ASSIST-V step in this
assignment.  You may wish to include STEP3 and/or STEP4 between
STEP2 and ASSIST-V as an aid in debugging your 'Load Module
Processing' code.  The JCL for STEP3 and STEP4 are given below.
STEP3 is a utility that produces a formatted print out of your
&&O(SVC8) Object Module.  STEP4 is a utility that produces a print
out of every byte (in hexadecimal) of your &&O(SVC8) object module.

//STEP3 EXEC PGM=AMBLIST
//SYSLIB DD DSN=&&O(SVC8),DISP=(OLD,PASS)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
   LISTOBJ
/*

//STEP4 EXEC PGM=IEBPTPCH
//SYSPRINT DD   SYSOUT=*
//SYSUT1 DD DSN=&&O(SVC8),DISP=(OLD,PASS)
//SYSUT2 DD   SYSOUT=*
//SYSIN DD *
   PRINT TOTCONV=XE
/*

  IN YOUR NEXT STEP, WHICH IS TO EXEC PGM=ASSISTV,
 YOUR //FT05F001 , ETC. SHOULD BE AS FOLLOWS.

//FT05F001 DD DSN=&&O(SVC8),DISP=(OLD,DELETE)
//         DD DSN=&&OO(SVC8),DISP=(OLD,DELETE)
//*  THESE PRECEDE THE 4 DD STATEMENTS NEEDED TO 
//*  RUN AN 'OBJMOD'.


In the NIP/MS you should use 'LOADER' to load your SVC8 from &&O into memory at X'7600'.  Then change the SVC table to use SVC 8 at X'7600'.  Use your SVC 8 to load your second copy of SVC 8 from &&OO into memory at X'7900'.  Change the SVC table to use SVCV 8 at X'7900'.  All future load will now use your 'twice loaded SVC 8 at X'7900'.  Note:  ORG the start of your SVC 13 to at least X'7C00'.

Like the SVC 8 described in the SOS-A handout, your SVC 8 will examine input parameters provided in R0 and R1.   It will attempt to load an object module that is available in an input file.  It will perform checks to verify that the length of the loaded program does not exceed the available space specified in R1 on entry to SVC 8.   It will perform the necessary text relocation, and determine the Entry Point Address (EPA) of the program.  The success or failure of the operation will be indicated by values returned in parameter registers to the program that issued the SVC 8.

On Entry   R0 = Address where program is to be loaded, or, if
                    R0 = -1, indicates program is to be loaded at
                             address contained in OM records.  Relocation Factor (RF) = 0.
                    R1 = Length of memory available for loading the OM at
                             the designated address.

On Exit:   R15 = 0 if the module was successfully loaded
                   R0 = Entry Point Address (EPA) of the loaded module
                   R1 = Length of the loaded module (from 1st ESD entry)
                   R15 = 4 if End of File (EOF) encountered while reading
                   R15 = 8 if length of csect exceeded R1 input size
                   R15 = 12 if input record was not a valid OM format
                   R15 = 16 if other categories of error occurred

1CSCI 468   Spring, 2007   LOADER - Lite   R.P. Rannie Page   3 of 4

Processing - General

On entry, your SVC 8 will initialize appropriate fields, including your fullword Relocation Factor (RF) to a value of F'-1'.  It will then read in an Object Module (OM) record.  Verify that it is a valid OM record and that it is one of the four OM record types.  Failing these tests, your SVC 8 should return with a Return Code (RC) in R15=12.  Your SVC 8 should have code to process each type of OM record.

All reading should be done in an internal subroutine.  It should be possible to create,via a '32n aligned ORG', EBCDIC identifiers for areas such as 16-Fullword Debug Area, IOB, Input buffer, and storage areas.

ESD Processing.

If RF .EQ. -1, this is the first ESD record.  You will process the first ESD entry (ESDID # 1) in this record after confirming that ESDID # 1 is a Section Definition (SD) (code = X'00' -- see notes on object modules)  Failing the SD test, you will end with RC = 16.

You will obtain the CSECT Address and the CSECT Length from the first ESD entry.  Compare the available memory (input in R1) with the CSECT Length.  End with RC = 8, if the CSECT Length is greater that the available memory specified in R1 on entry to SVC 8.  Save (or hold in a register) the CSECT Address.

Calculate the Relocation Factor (RF) defined as the memory address specified in R0 on entry to SVC 8 minus the CSECT Address in the first ESD entry.  Save (or hold in a register) this value for use in subsequent processing.

If the contents of R0 on entry to SVC 8 are -1, then RF=0 is to be applied.  Accordingly, the OM is to be loaded into the address in memory that corresponds to the address used when the program was assembled.  This should be handled by setting your RF to zero.

At this point you will read the next OM record.  Note that if on entry to the ESD code, RF .NE. -1, you will discard this and following ESD records by going directly to read the next OM record.

1CSCI 468   Spring, 2007   LOADER - Lite   R.P. Rannie Page   4 of 4

TXT Processing

If on entry to this section of code, RF .EQ. -1, there is an error, and you should return with RC = 16.  If RF .NE. -1 proceed as follows.  Verify that the length of text on this record is not zero.  If it is, return with RC = 16.  Obtain the address of this section of text and apply the RF to obtain the real memory address.  Use an EX of a MVC instruction to move the text to the correct real memory location.  Now read the next OM record.

RLD Processing

In this loader you should read the next OM record when the record you have just read is an RLD record.  This looping will discard all of the RLD records.

END Processing

On entry to END record processing, test a flag byte to verify that at least one TXT record was processed.  If no TXT records were processed, return with RC=16.

On the END record, test the 'address of entry point' field for three 'blanks'.  If this is the value in this field, the Entry Point Address (EPA) you will return in R0 will be the CSECT Address found in the first ESD record (after correcting for the RF).  If the three byte field is not three 'blanks', this is the address of the EPA (which must be corrected for the RF) that is to be returned in R0.

Load R1 with CSECT Length, load EPA into R0, set RC = 0, and exit.

Append the following LABELS on the Extended Mnemonic Branch Instructions that designate the code handling the following error conditions.  Common nomenclature will simplify identification of your tests for these circumstances.

RC0    Normal return, successful.
RC4    End of File (EOF) encountered on read.
RC8    Size of CSECT too large for memory area.
RC12#1 First byte of OM? record is not X'02'.
RC12#2 Second through Fourth bytes of OM? record are not
        ESD, TXT, RLD, or END.
RC16#1 First ESD entry is not 'SD', i.e., X'00'.
RC16#2 TXT record was not preceded by ESD record, RF still = -1.
RC16#3 Length of the text in TXT record was zero.
RC16#4 No TXT records were processed.