Macro – @DUMP

Next we will create a macro to dump a block of memory.  It will call our @PRINT macro to write the dump to the printer device. Like the @PRINT macro there are two forms GEN=YES and GEN=NO.

         MACRO
&NAME    @DUMP &ADDR,&LEN,&GEN=NO
         LCLC  &NDX
&NDX     SETC  '&SYSNDX'
         AIF   ('&GEN' EQ 'YES').GEN
&NAME    @RGCK &ADDR,REG=R1
         @RGCK &LEN,REG=R0
         LA    R15,@DUMP
         BALR  R14,R15
         MEXIT ,

We start just like the @PRINT macro and set up a variable for generating local labels.  The beginning address of the storage to be dumped is placed into register 1 using the @RGCK macro and the length to dump is loaded into register 0.  Our subroutine @DUMP is then called to format and print the storage.

.GEN     ANOP  ,
@DUMP    STM   R14,R12,12(R13)
         LA    R15,@&NDX.80       NEW SAVE AREA
         ST    R15,8(,R13)
         ST    R13,4(,R15)
         LR    R13,R15
*
         LR    R10,R1             DATA ADDRESS
         LR    R11,R0             LENGTH
         AR    R11,R10            END ADDRESS
*
         N     R10,@&NDX.83       ALIGN

We start by saving the callers registers in the save area provided by the caller pointed to by register 13.  We then chain on our save area and copy the data address into register 10 and the length into register 11.  If the beginning address does not begin on an even boundary we back it up using an AND with a mask of  X’00FFFFF0′.

@&NDX.01 DS    0H
         MVI   @&NDX.70,C' '      CLEAR PRINT BUFFER
         MVC   @&NDX.70+1(L'@&NDX.70-1),@&NDX.70
         ST    R10,@&NDX.81       ADDRESS
         UNPK  @&NDX.82(9),@&NDX.81(5)
         TR    @&NDX.82(8),@&NDX.99-C'0'
         MVC   @&NDX.71,@&NDX.82
*
         MVC   @&NDX.74,0(R10)
         TR    @&NDX.74,@&NDX.98  KEEP ONLY PRINTABLE

Now we start the main outer loop by clearing out our print buffer.  Next we save the address into a full word work area.  Using the UNPK instruction and a TR we convert it to printable characters.  The UNPK will convert each byte into two bytes with the value X’F0′ to X’FF’.  Our translation table contains ‘0123456789ABCDEF’.  By using the address of our translate table and subtracting our offset of X’F0′ (C’0′) we have translated a hex address to a printable string.

We then copy the target data are to our print buffer and using a second translate table we convert any unprintable characters to a period (x’4B’).

*
         LA    R2,@&NDX.72        FIRST DATA AREA
         LA    R3,4
@&NDX.02 DS    0H
         MVC   @&NDX.81(4),0(R10)
         UNPK  @&NDX.82(9),@&NDX.81(5)
         TR    @&NDX.82(8),@&NDX.99-C'0'
         MVC   0(8,R2),@&NDX.82
         LA    R10,4(,R10)
         LA    R2,9(,R2)
         BCT   R3,@&NDX.02
*

Now we set up for the inner loop to translate the 16 bytes of data into printable strings.  We set up the loop with register 2 pointing into the print buffer and register 3 with a value of 4 (4 groups of 4 bytes).

Using the same sequence of UNKP and TR we translate the data contents  into hex data strings.  We then increment the source and target pointers and use BCT to loop back if still more data to process for the line.

*
         @PRINT @&NDX.70
*
*
         CR    R10,R11            STILL MORE TO DO
         BL    @&NDX.01           YES - LOOP BACK
*
*
         L     R13,4(,R13)
         LM    R14,R12,12(R13)
         BR    R14
*

Now we use our @PRINT macro to print the formatted line.  Next we check to see if we have reached our end address.  If not we loop back and print another line.  When done we unchain the save area, restore registers and return to the caller.

*
@&NDX.70 DC    CL132' '
         ORG   @&NDX.70
@&NDX.71 DS    CL8
         DS    CL2
@&NDX.72 DS    CL8,CL1,CL8,CL1,CL8,CL1,CL8,CL2
@&NDX.74 DS    CL16
         ORG   ,
*
@&NDX.80 DC    18F'0'
@&NDX.81 DC    F'0'
@&NDX.82 DC    CL9'0'
         DS    0F
@&NDX.83 DC    X'00FFFFF0'
*

All that is left is to define our data area.  First is our print buffer which is 132 bytes long.  Using ORG we overlay it with our data fields for the storage address, the hex representation of the data and the character representation.

We then define our save area, our work area for the UNPK processing and our beginning address mask.

Finally we define our two translate tables (see full listing).

Full macro listing below:


         MACRO                                                 
&NAME    @DUMP &ADDR,&LEN,&GEN=NO                              
         LCLC  &NDX                                            
&NDX     SETC  '&SYSNDX'                                       
         AIF   ('&GEN' EQ 'YES').GEN                           
&NAME    @RGCK &ADDR,REG=R1                                    
         @RGCK &LEN,REG=R0                                     
         LA    R15,@DUMP                                       
         BALR  R14,R15                                         
         MEXIT ,                                               
.*                                                             
.*                                                             
.GEN     ANOP  ,                                               
@DUMP    STM   R14,R12,12(R13)                                 
         LA    R15,@&NDX.80       NEW SAVE AREA                
         ST    R15,8(,R13)                                     
         ST    R13,4(,R15)                                     
         LR    R13,R15                                         
*                                                              
         LR    R10,R1             DATA ADDRESS                 
         LR    R11,R0             LENGTH                      
         AR    R11,R10            END ADDRESS                       
*                                                                   
         N     R10,@&NDX.83       ALIGN                             
@&NDX.01 DS    0H                                                   
         MVI   @&NDX.70,C' '      CLEAR PRINT BUFFER                
         MVC   @&NDX.70+1(L'@&NDX.70-1),@&NDX.70                    
         ST    R10,@&NDX.81       ADDRESS                           
         UNPK  @&NDX.82(9),@&NDX.81(5)                              
         TR    @&NDX.82(8),@&NDX.99-C'0'                            
         MVC   @&NDX.71,@&NDX.82                                    
*                                                                   
         MVC   @&NDX.74,0(R10)                                      
         TR    @&NDX.74,@&NDX.98  KEEP ONLY PRINTABLE               
*                                                                   
         LA    R2,@&NDX.72        FIRST DATA AREA                   
         LA    R3,4                                                 
@&NDX.02 DS    0H                                                   
         MVC   @&NDX.81(4),0(R10)                                   
         UNPK  @&NDX.82(9),@&NDX.81(5)                              
         TR    @&NDX.82(8),@&NDX.99-C'0'                            
         MVC   0(8,R2),@&NDX.82
         LA    R10,4(,R10)                                
         LA    R2,9(,R2)                                  
         BCT   R3,@&NDX.02                                
*                                                         
*                                                         
         @PRINT @&NDX.70                                  
*                                                         
*                                                         
         CR    R10,R11            STILL MORE TO DO        
         BL    @&NDX.01           YES - LOOP BACK         
*                                                         
*                                                         
         L     R13,4(,R13)                                
         LM    R14,R12,12(R13)                            
         BR    R14                                        
*                                                         
*                                                         
@&NDX.70 DC    CL132' '                                   
         ORG   @&NDX.70                                   
@&NDX.71 DS    CL8                                        
         DS    CL2
@&NDX.72 DS    CL8,CL1,CL8,CL1,CL8,CL1,CL8,CL2                  
@&NDX.74 DS    CL16                                             
         ORG   ,                                                
*                                                               
@&NDX.80 DC    18F'0'                                           
@&NDX.81 DC    F'0'                                             
@&NDX.82 DC    CL9'0'                                           
         DS    0F                                               
@&NDX.83 DC    X'00FFFFF0'                                      
*                                                               
*                                                               
@&NDX.98 DS    0C                                               
*                 0 1 2 3 4 5 6 7 8 9 A B C D E F               
         DC    X'4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B'  00          
         DC    X'4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B'  10          
         DC    X'4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B'  20          
         DC    X'4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B'  30          
         DC    X'4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B'  40          
         DC    X'504B4B4B4B4B4B4B4B4B5A5B5C5D5E5F'  50          
         DC    X'60614B4B4B4B4B4B4B4B6A6B6C6D6E6F'  60          
         DC    X'4B4B4B4B4B4B4B4B4B4B7A7B7C7D7E7F'  70
         DC    X'4BC1C2C3C4C5C6C7C8C94B4B4B4B4B4B'  80         
         DC    X'4BD1D2D3D4D5D6D7D8D94B4B4B4B4B4B'  90         
         DC    X'4B4BE2E3E4E5E6E7E8E94B4B4B4B4B4B'  A0         
         DC    X'4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B4B'  B0         
         DC    X'4BC1C2C3C4C5C6C7C8C94B4B4B4B4B4B'  C0         
         DC    X'4BD1D2D3D4D5D6D7D8D94B4B4B4B4B4B'  D0         
         DC    X'4B4BE2E3E4E5E6E7E8E94B4B4B4B4B4B'  E0         
         DC    X'F0F1F2F3F4F5F6F7F8F94B4B4B4B4B4B'  F0         
*                                                              
*                                                              
@&NDX.99 DC    C'0123456789ABCDEF'                             
         MEND  ,

[Next – Macro @CARD]

Macro – @PRINT

The @PRINT macro will allow us to print a single line to a printer.  By default the printer is assumed to be a the standard address x’00E’.  There are two forms of this macro –  GEN=YES and GEN=NO.  GEN=NO is the default form and is used to generate a call to our subroutine to print a line.  The GEN=YES form is used to generate the code for our print subroutine.

          MACRO
 &NAME    @PRINT &DATA,&LEN=132,&DEV=X'00E',&GEN=NO
          LCLC   &NDX
          LCLA   &K
 &NDX     SETC   '&SYSNDX'
          AIF    ('&GEN' EQ 'YES').GEN

We being by defining a couple of macro local variables – &NDX and &K.  We set &NDX to the value contained in the assembler &SYSNDX which will contain a unique number for each macro invocation.  We will use this to generate unique lable values in our macros.  Next we test to see if GEN=YES has been specified and if so we branch to generate the subroutine code.

          AIF    ('&DATA'(1,1) EQ '''').STRING
 &NAME    @RGCK  &DATA,REG=R1
          @RGCK  &LEN,REG=R0
          LA     R15,@PRINT
          BALR   R14,R15
          MEXIT  ,

Next we check to see if our &DATA parameter is a string.  We check this before using the @RGCK macro because we want to use the length of the string in our macro.  If not a string then we load the data target address into R1 and the data length into R0 (using a length of 132 as a default).  We then BALR to our print subroutine.

 .STRING  ANOP   ,
  &NAME   LA     R1,=C&DATA
  &K      SETA   K'&DATA
  &K      SETA   &K-2
          LA     R0,&K
          LA     R15,@PRINT
          BALR   R14,R15
          MEXIT  ,

Here we generate a LA to place the address of a literal string into R1.  We set &K to the length of the string operand and subtract two (for the beginning and ending quotes) to get the data length which we place in R0.  We then call the print subroutine.

We will use a standard OS save area and linkage.  We could use any other approach since we are not interfacing with the operating system – we are the operating system!  We will always expect R13 to contain the address of a 18 word save area.

 .GEN     ANOP   ,
 @PRINT   STM    R14,R12,12(R13)        SAVE CALLERS REGISTERS
          LR     R2,R1                  POINT TO DATA TO PRINT
          LR     R3,R0                  LENGTH OF DATA TO PRINT
          LA     R1,132                 MAX LENGTH WE CAN PRINT
          CR     R3,R1                  TOO BIG
          BNH    @&NDX.01               NO - BRANCH
          LR     R3,R1                  SET TO MAX
 @&NDX.01 DS     0H

Now we copy the data address into R2 although we could have left it in R1 but out of habit I copied it freeing up R1.  We then copy the length from R0 into R3 and compare it to the max length of 132.  If the length is larger than the max we set it to the max value.

          ST     R2,@&NDX.90            SAVE DATA ADDR INTO CCW
          MVI    @&NDX.90,X'09'         PRINT: SINGLE SPACE
          ST     R3,@&NDX.90+4          SAVE LENGTH INTO CCW
          LA     R1,@&NDX.90            POINT TO CCW
          ST     R1,72                  SAVE INTO CAW
          LA     R2,&DEV                GET PRINT DEVICE ADDRESS
          SIO    0(R2)
          BNZ    @&NDX.81               BRANCH IF ERROR

Next we place the data address into the CCW.  We then set our CCW Op Code to X’09’ to print and single space followed by the length of the data.  We then get the address of our CCW and store it into the Channel Address Word at fixed location 72.  We can then issue a SIO to the printer using the device address from our macro parameter &DEV.  We check to verify the SIO was accepted and if not we branch to an error routine to load a wait state PSW.

 @&NDX.02 DS     0H
          TIO    0(R2)                  WAIT FOR I/O TO COMPLETE
          BZ     @&NDX.03               COMPLETE
          BC     1,@&NDX.82             BRANCH IF ERROR
          B      @&NDX.02               LOOP BACK AND WAIT
 *
 @&NDX.03 DS     0H
          LM     R14,R12,12(R13)        RESTORE REGISTERS
          BR     R14

A TIO loop is executed until the I/O is complete and then we can restore the registers and return to the caller.

 @&NDX.81 LPSW   @ERRPRT1               LOAD WAIT PSW
 @&NDX.82 LPSW   @ERRPRT2               LOAD WAIT PSW
          DS     0D
 @&NDX.90 DC     X'00',AL3(0),X'00',X'00',AL2(0)  CCW
          MEND   ,

Now all we have left to is it define our error routines to load a wait state PSW.  Our error PSW definitions are in our @ERR macro.  We also need to allocate the space where we will construct our CCW.

Now we can print to the printer using our macro.

         @PRINT 'HELLO, WORLD'        * Print Hello Message

         @PRINT ' '                   * Print a Blank Line

         @PRINT MSG,LEN=9             * Print string 8 chars long
MSG      DC     C'HI, WORLD'

         @PRINT (AMSG)                * Print 132 char string
AMSG     DC     A(OURMSG)
OURMSG   DC     CL132'*** THIS IS OUR MESSAGE ***'

         LA     R10,OURMSG            * Print 132 char string
         @PRINT (R10)

Full macro listing is below.


          MACRO                                                  
 &NAME    @PRINT &DATA,&LEN=132,&DEV=X'00E',&GEN=NO
          LCLC   &NDX                                            
          LCLA   &K                                              
 &NDX     SETC   '&SYSNDX'                                       
          AIF    ('&GEN' EQ 'YES').GEN                           
          AIF    ('&DATA'(1,1) EQ '''').STRING                   
 &NAME    @RGCK  &DATA,REG=R1                                    
          @RGCK  &LEN,REG=R0                                     
          LA     R15,@PRINT                                      
          BALR   R14,R15                                         
          MEXIT  ,                                               
 .*                                                              
 .*                                                              
 .STRING  ANOP   ,                                               
  &NAME   LA     R1,=C&DATA                                      
  &K       SETA   K'&DATA                                         
  &K       SETA   &K-2                                            
           LA     R0,&K                                           
           LA     R15,@PRINT                                     
           BALR   R14,R15                                               
           MEXIT  ,                                                     
 .*                                                                    
 .*                                                                    
 .GEN     ANOP   ,                                                     
 @PRINT   STM    R14,R12,12(R13)        SAVE CALLERS REGISTERS         
          LR     R2,R1                  POINT TO DATA TO PRINT         
          LR     R3,R0                  LENGTH OF DATA TO PRINT        
          LA     R1,132                 MAX LENGTH WE CAN PRINT        
          CR     R3,R1                  TOO BIG                        
          BNH    @&NDX.01               NO - BRANCH                    
          LR     R3,R1                  SET TO MAX                     
 @&NDX.01 DS     0H                                                    
          ST     R2,@&NDX.90            SAVE DATA ADDR INTO CCW        
          MVI    @&NDX.90,X'09'         PRINT: SINGLE SPACE            
          ST     R3,@&NDX.90+4          SAVE LENGTH INTO CCW           
          LA     R1,@&NDX.90            POINT TO CCW                   
          ST     R1,72                  SAVE INTO CAW                  
          LA     R2,&DEV                GET PRINT DEVICE ADDRESS       
          SIO    0(R2)                                                 
          BNZ    @&NDX.81               BRANCH IF ERROR               
 @&NDX.02 DS     0H                                                    
          TIO    0(R2)                  WAIT FOR I/O TO COMPLETE       
          BZ     @&NDX.03               COMPLETE                       
          BC     1,@&NDX.82             BRANCH IF ERROR                
          B      @&NDX.02               LOOP BACK AND WAIT             
 *                                                                     
 @&NDX.03 DS     0H                                                    
          LM     R14,R12,12(R13)        RESTORE REGISTERS              
          BR     R14                                                   
 *                                                                     
 @&NDX.81 LPSW   @ERRPRT1               LOAD WAIT PSW                  
 @&NDX.82 LPSW   @ERRPRT2               LOAD WAIT PSW                  
          DS     0D                                                    
 @&NDX.90 DC     X'00',AL3(0),X'00',X'00',AL2(0)  CCW                  
          MEND   ,

[Next – Macro @DUMP]

Macro – @RGCK

Our next macro is a utility macro to help us load data into a register.

The macro will examine the operand and determine what action to take.  There are four possible actions depending on the operand.

(Rx) – will generate a LR to load the target register from the operand register Rx

(addr) – Will generate a L to load the target register with the data at address location addr.

addr – Will generage a LA to load the target register with the value addr

‘string’ – Will generate a LA to load the target register with a literal string.  The default string type is C for character.  Optionally a length may be specified.

         MACRO
&NAME    @RGCK &FLD,&REG=,&LEN=,&TYPE=C

The macro has four parameters, two of which must be specified.  &FLD is the operand.  &REG is the target register and should be specified in using an Equated value (Rx).  &LEN  is optional and is used to specify a length when a literal string is generated.  If &LEN is not specified, no explicit length will be used for the literal.  &TYPE indicates the type of literal to be generated.  If &TYPE is not specified, C will be assumed for character.

         AIF   ('&FLD'(1,1) NE '(').NOREG
         AIF   ('&FLD(1)'  EQ '&REG').DONE
.*
         AIF   ('&FLD(1)' EQ 'R0').LR
         AIF   ('&FLD(1)' EQ 'R1').LR

First we check to see if the operand is enclosed in parentheses indicating either a register or a target for a LA.  We do this by checking the first character of the &FLD parameter.  If the target and operand registers are both the same then there is nothing to be done and we can exit.  Else the operand is checked against the our standard register equate names (Rx).  If it matches a value from R0 – R16 we branch to the .LR label.

         AIF   ('&FLD(1)' EQ 'R15').LR
.*
&NAME    L     &REG,&FLD(1)
         MEXIT ,

If no match is found we fall through the tests and generate a L instruction.

.NOREG   ANOP  ,
         AIF   ('&FLD'(1,1) EQ '''').STRING
&NAME    LA    &REG,&FLD(1)
         MEXIT ,
.*
.*

Now we check for a string indicated by a single quote in the first position of the operand.  If it is not a string we generate a LA.

.STRING  ANOP  ,
         AIF   (T'&LEN EQ 'O').NOLEN
&NAME    LA    &REG,=&TYPE.L&LEN&FLD
         MEXIT ,
.NOLEN   ANOP  ,
&NAME    LA    &REG,=&TYPE&FLD
          MEND

If it is a string we check to see if a length value (&LEN) is specified.  If not we generate a LA for a literal with no length specification.  Else we generate the LA using the specified length value for our literal.

Below is the full macro.


         MACRO
&NAME    @RGCK &FLD,&REG=,&LEN=,&TYPE=C
.*
         AIF   ('&FLD'(1,1) NE '(').NOREG
         AIF   ('&FLD(1)'  EQ '&REG').DONE
.*
         AIF   ('&FLD(1)' EQ 'R0').LR
         AIF   ('&FLD(1)' EQ 'R1').LR
         AIF   ('&FLD(1)' EQ 'R2').LR
         AIF   ('&FLD(1)' EQ 'R3').LR
         AIF   ('&FLD(1)' EQ 'R4').LR
         AIF   ('&FLD(1)' EQ 'R5').LR
         AIF   ('&FLD(1)' EQ 'R6').LR
         AIF   ('&FLD(1)' EQ 'R7').LR
         AIF   ('&FLD(1)' EQ 'R8').LR
         AIF   ('&FLD(1)' EQ 'R9').LR
         AIF   ('&FLD(1)' EQ 'R10').LR
         AIF   ('&FLD(1)' EQ 'R11').LR
         AIF   ('&FLD(1)' EQ 'R12').LR
         AIF   ('&FLD(1)' EQ 'R13').LR
         AIF   ('&FLD(1)' EQ 'R14').LR
         AIF   ('&FLD(1)' EQ 'R15').LR
.*
&NAME    L     &REG,&FLD(1)
         MEXIT ,
.*
.*
.LR      ANOP  ,
&NAME    LR    &REG,&FLD(1)
.DONE    ANOP  ,
         MEXIT ,
.*
.*
.NOREG   ANOP  ,
         AIF   ('&FLD'(1,1) EQ '''').STRING
&NAME    LA    &REG,&FLD(1)
         MEXIT ,
.*
.*
.STRING  ANOP  ,
         AIF   (T'&LEN EQ 'O').NOLEN
&NAME    LA    &REG,=&TYPE.L&LEN&FLD
         MEXIT ,
.NOLEN   ANOP  ,
&NAME    LA    &REG,=&TYPE&FLD
          MEND

[Next – Macro @PRINT]

Macro – @ERR

Our next macro will be used to help us keep track of error codes used a PSW Wait State codes.  Each is a Wait State PSW and we will being each error code with X’BE’.  Our first two error codes are for our printing macro.

         MACRO
         @ERR
         DS   0D
@ERRPRT1 DC   X'0002000000',X'BE0001'
@ERRPRT2 DC   X'0002000000',X'BE0002'
         MEND ,

[Next – Macro @RGCK]

Macro – @REGS

Our fist macro will simply generate an Equate for each of the sixteen registers.  This allows us to refer to a register using a symbolic name.  By doing so our register usage will be in the assembler cross reference.

         MACRO
         @REGS ,
R0       EQU   0
R1       EQU   1
R2       EQU   2
R3       EQU   3
R4       EQU   4
R5       EQU   5
R6       EQU   6
R7       EQU   7
R8       EQU   8
R9       EQU   9
R10      EQU   10
R11      EQU   11
R12      EQU   12
R13      EQU   13
R14      EQU   14
R15      EQU   15
         MEND  ,

[Next – Macro @ERR]

Building Some Useful Macros

Now that we have our Object Deck Loader we can start thinking about building some more complex stand alone programs.  In order to make this task easier we will start by writing some assembler macros to handle some basic tasks like printing a line to a printer, dumping storage and reading a card from the card reader.

We will begin with some macros to  take care of some common utility functions.

[Next – Macro @REGS]

Testing The Absolute Loader

We can write a very small and simple program very quickly to test our Object Deck Loader program.

ABSTEST1 START 0
         DC    X'02',x'00',X'0000',X'00',X'00FACE'
         END   ,

To test the loader I created some JCL with two steps. The first step runs the Object Deck Loader program to punch out the 5 cards for our IPL deck. The second step assembles our test program and punches the Object Deck to the punch so it will immediately follow our IPL deck.

//TXXABST1 JOB 5222,'Loader Test',CLASS=A,MSGCLASS=A
//*
//TXXOSRUN EXEC PGM=ABSLOAD
//STEPLIB    DD DISP=SHR,DSN=TXXOS.CARD.LOAD
//PUNCH      DD UNIT=00D
//*
//ASM     EXEC PGM=IFOX00,REGION=1024K,PARM='LINECOUNT(44)'
//SYSLIB    DD DISP=SHR,DSN=SYS1.MACLIB
//SYSUT1    DD DSN=&&SYSUT1,UNIT=VIO,SPACE=(1700,(600,100))
//SYSUT2    DD DSN=&&SYSUT2,UNIT=VIO,SPACE=(1700,(300,50))
//SYSUT3    DD DSN=&&SYSUT3,UNIT=VIO,SPACE=(1700,(300,50))
//SYSPRINT  DD SYSOUT=*
//SYSPUNCH  DD UNIT=00D
//SYSIN     DD DISP=SHR,DSN=TXXOS.CARD.ASM(ABSTEST1)

As before we can run on our MVS system and create a card deck file to IPL from. When we IPL using our Object Deck Loader followed by our ABSTEST1 Object Deck program our Hercules CPU should enter a wait state with X’FACE’ in the low order data.

[Next – Creating Some Useful Macros]

Absolute Loader Description

The Absolute Loader is very similar to our CARD80 program. It begins with the first IPL record containing a PSW and two CCW’s. The address to use for the Loader is specified with the equate for the symbol CLA (Card Loader Address). Here we set it to 8K but it could be changed to something else as long as it does not overlap the memory used by the object deck we are loading.

CLA EQU 1024*8 LOCATION TO LOAD THE LOADER
*
* PSW
*
IPLPSW  DC    X'00'         I/O & EXT Interrupts Disabled
        DC    X'00'         Key=0; BC; EXT INT Disabled; SUP
        DC    X'0000'       
        DC    X'00'         PROG Interrupts Disabled
        DC    AL3(CLA+80)   Initial Execution Address
*
CCW1    DC    X'02'         Read Card
        DC    AL3(CLA+0)    Data Address
        DC    X'60'         CC+SLI
        DC    X'00'
        DC    AL2(80)       Length
*
CCW2    DC    X'028         TIC
        DC    AL3(CLA+0)    Next CCW Address
        DC    X'00'         
        DC    X'00'
        DC    AL2(0)        Length

The second card contains three CCW’s to read three cards into memory.

*
CCW3    DC    X'02'         Read Card
        DC    AL3(CLA+80)   Data Address
        DC    X'60'         CC+SLI
        DC    X'00'
        DC    AL2(80)       Length
*
CCW4    DC    X'02'         Read Card
        DC    AL3(CLA+160)  Data Address
        DC    X'60'         CC+SLI
        DC    X'00'
        DC    AL2(80)       Length
*
CCW5    DC    X'02'         Read Card
        DC    AL3(CLA+240)  Data Address
        DC    X'20'         SLI
        DC    X'00'
        DC    AL2(80)       Length
*

The next three cards contain our executable program. As before we establish a base register and then we get the address of the IPL device (card reader) and save in R3.  We get the address of our input buffer and store it in our Read CCW.

Now we begin our processing  loop by issuing a SIO to read a card.  We wait for the I/O to complete and then check for successful status.  If the I/O operation does not complete successfully we load a Wait State PSW and halt execution.

Next we check the contents of the card we just read.  If it is an object deck it should  have a X’02’ in column one.  Next we check to see what type of record it is.  For SYM, ESD and RLD records we simply ignore it and read the next card.

When we read a TXT record we get the target data address contained in the TXT record and the data length.  This tells us how many bytes of data to copy and where to copy it to.  We copy the data using an executed MVC instruction.  We can then loop back and process the next card.

When we read an END card we simply issue a LPSW  to load the new PSW from location zero.  It is the responsibility of the program we just loaded to include a new PSW at location zero.

We use the program-within-a-program technique to punch our loader deck to the card punch unit.

[Next – Testing The Absolute Loader]

Absolute Loader Assembly Listing

ABSLOAD   SD  0001 000000 000358                                                                                                               PAGE    2

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

                                      1 **********************************************************************  00010000
                                      2 * ABSLOAD                                                               00020000
                                      3 *                                                                       00030000
                                      4 * ABSOLUTE OBJECT DECK LOADER.  WILL READ AN OBJECT DECK FROM THE       00040000
                                      5 * READER IMMEDIATELY FOLLOWING THE LOADER AND TRANSFER CONTROL TO       00050000
                                      6 * TO LOADED PROGRAM                                                     00060000
                                      7 *                                                                       00070000
                                      8 **********************************************************************  00080000
000000                                9 ABSLOAD  CSECT ,                                                        00090000
000000 90EC D00C      0000C          10          STM   R14,R12,12(R13)    SAVE CALLERS REGISTERS                00100000
000004 18CF                          11          LR    R12,R15            R12 IS PROGRAM BASE                   00110000
                            00000    12          USING ABSLOAD,R12                                              00120000
                                     13 *                                                                       00130000
000006 4110 C0D0      000D0          14          LA    R1,SAVEA           POINT TO NEW SAVE AREA                00140000
00000A 5010 D008      00008          15          ST    R1,8(,R13)         CHAIN                                 00150000
00000E 50D0 1004      00004          16          ST    R13,4(,R1)              ON                               00160000
000012 18D1                          17          LR    R13,R1                    SAVEAREA                       00170000
                                     18 *                                                                       00180000
                                     19 *                                                                       00190000
                                     20          OPEN  (PUNCH,OUTPUT)     OPEN OUTPUT FILE                      00200000
000014                               21+         CNOP  0,4                               ALIGN LIST TO FULLWORD 01740001
000014 4510 C01C      0001C          22+         BAL   1,*+8                             LOAD REG1 W/LIST ADDR. 01780000
000018 8F                            23+         DC    AL1(143)                          OPTION BYTE            01900000
000019 000118                        24+         DC    AL3(PUNCH)                        DCB ADDRESS            01920000
00001C 0A13                          25+         SVC   19                                ISSUE OPEN SVC         04000000
                                     26 **********************************************************************  00210000
                                     27 *  WRITE FIRST IPL CARD WITH 24 BYTES OF DATA (PSW,CCW,CCW)             00220000
                                     28 **********************************************************************  00230000
                                     29          PUT   PUNCH,CARD0        WRITE INITIAL IPL RECORD              00240000
00001E 4110 C118      00118          30+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
000022 4100 C178      00178          31+         LA    0,CARD0                           LOAD PARAMETER REG 0   02500002
000026 58F0 1030      00030          32+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
00002A 05EF                          33+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     34 **********************************************************************  00250000
                                     35 *  WRITE SECOND IPL CARD WITH ADDITIONAL READ CCW'S                     00260000
                                     36 **********************************************************************  00270000
                                     37          PUT   PUNCH,CARD1        WRITE SECOND IPL RECORD               00280000
00002C 4110 C118      00118          38+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
000030 4100 C1C8      001C8          39+         LA    0,CARD1                           LOAD PARAMETER REG 0   02500002
000034 58F0 1030      00030          40+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000038 05EF                          41+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     42 **********************************************************************  00290000
                                     43 *  WRITE 3 CARDS CONTAINING EXECUTABLE CODE                             00300000
                                     44 **********************************************************************  00310000                                                                                                               PAGE    3

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

                                     45          PUT   PUNCH,CARD2        WRITE DATA                            00320000
00003A 4110 C118      00118          46+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00003E 4100 C218      00218          47+         LA    0,CARD2                           LOAD PARAMETER REG 0   02500002
000042 58F0 1030      00030          48+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000046 05EF                          49+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     50          PUT   PUNCH,CARD2+80     WRITE DATA                            00330000
000048 4110 C118      00118          51+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00004C 4100 C268      00268          52+         LA    0,CARD2+80                        LOAD PARAMETER REG 0   02500002
000050 58F0 1030      00030          53+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000054 05EF                          54+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     55          PUT   PUNCH,CARD2+160    WRITE DATA                            00340000
000056 4110 C118      00118          56+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00005A 4100 C2B8      002B8          57+         LA    0,CARD2+160                       LOAD PARAMETER REG 0   02500002
00005E 58F0 1030      00030          58+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000062 05EF                          59+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     60 **********************************************************************  00350000
                                     61 *                                                                       00360000
                                     62 *        ALL DONE CLOSE UP AND EXIT                                     00370000
                                     63 *                                                                       00380000
                                     64 **********************************************************************  00390000
                                     65 *                                                                       00400000
                                     66          CLOSE (PUNCH)                                                  00410000
000064                               67+         CNOP  0,4                               ALIGN LIST TO FULLWORD 02420002
000064 4510 C06C      0006C          68+         BAL   1,*+8                             LOAD REG1 W/LIST ADDR  02460002
000068 80                            69+         DC    AL1(128)                          OPTION BYTE            02580000
000069 000118                        70+         DC    AL3(PUNCH)                        DCB ADDRESS            02600000
00006C 0A14                          71+         SVC   20                                ISSUE CLOSE SVC        01640000
                                     72 *                                                                       00420000
                                     73 *                                                                       00430000
00006E 58D0 D004      00004          74          L     R13,4(,R13)        PREV SAVE AREA                        00440000
000072 98EC D00C      0000C          75          LM    R14,R12,12(R13)    RESTORE CALLERS REGISTERS             00450000
000076 1FFF                          76          SLR   R15,R15            RC=0                                  00460000
000078 07FE                          77          BR    R14                                                      00470000
                                     78 *                                                                       00480000
000080                               79          LTORG ,                                                        00490000
                                     80 *                                                                       00500000
000080                               81 BUF      DS    CL80               CARD BUFFER                           00510000
                                     82 *                                                                       00520000
0000D0                               83 SAVEA    DS    18F                SAVEA AREA                            00530000
                                     84 *                                                                       00540000
                                     85 *                                                                       00550000
                                     86          PRINT NOGEN                                                    00560000
                                     87 PUNCH    DCB   DSORG=PS,MACRF=PM,BLKSIZE=80,LRECL=80,RECFM=F,          +00570000
                                                       DDNAME=PUNCH                                             00580000                                                                                                               PAGE    4

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

                                    141          PRINT GEN                                                      00590000
                                    142 *                                                                       00600000
                                    143 *                                                                       00610000
                                    144          DROP  R12                                                      00620000
                                    145 *                                                                       00630000
                                    146 *                                                                       00640000
                            02000   147 CLA      EQU   1024*8             LOCATION TO LOAD THE LOADER           00650000
                                    148 *                                                                       00660000
                                    149 *                                                                       00670000
                                    150 **********************************************************************  00680000
                                    151 **********************************************************************  00690000
                                    152 ** FRIST CARD OF OUR IPL DECK                                           00700000
                                    153 **    IT CONTAINS 24 BYTES - PSW AND TWO CCW'S                          00710000
                                    154 **********************************************************************  00720000
                                    155 **********************************************************************  00730000
                                    156 *                                                                       00740000
000178                              157          DS    0D                                                       00750000
000178 0000000000000000             158 CARD0    DC    80XL1'00'          INITIAL IPL CARD                      00760000
0001C8                      00178   159          ORG   CARD0                                                    00770000
                                    160 *                                                                       00780000
                                    161 **********************************************************************  00790000
                                    162 *        PSW                                                            00800000
                                    163 **********************************************************************  00810000
                                    164 *                                                                       00820000
000178 00                           165 IPLPSW   DC    X'00'              I/O & EXT INTERRUPTS DISABLED         00830000
000179 00                           166          DC    X'00'              KEY=0; BC; EXT INT DISABLED; SUP      00840000
00017A 0000                         167          DC    X'0000'                                                  00850000
00017C 00                           168          DC    X'00'              PROG INT DISABLED                     00860000
00017D 002050                       169          DC    AL3(CLA+80)        INITIAL EXECUTION ADDRESS             00870000
                                    170 *                                                                       00880000
                                    171 **********************************************************************  00890000
                                    172 *        CCW                                                            00900000
                                    173 **********************************************************************  00910000
                                    174 *                                                                       00920000
000180 02                           175 CCW1     DC    X'02'              READ                                  00930000
000181 002000                       176          DC    AL3(CLA+0)         ADDRESS FOR DATA                      00940000
000184 60                           177          DC    X'60'              CC + SLI                              00950000
000185 00                           178          DC    X'00'                                                    00960000
000186 0050                         179          DC    AL2(80)            LENGTH                                00970000
                                    180 *                                                                       00980000
                                    181 **********************************************************************  00990000
                                    182 *        CCW                                                            01000000
                                    183 **********************************************************************  01010000
                                    184 *                                                                       01020000
                                                                                                               PAGE    5

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

000188 08                           185 CCW2     DC    X'08'              TIC                                   01030000
000189 002000                       186          DC    AL3(CLA+0)         NEXT CCW ADDRESS                      01040000
00018C 00                           187          DC    X'00'              CC + SLI                              01050000
00018D 00                           188          DC    X'00'                                                    01060000
00018E 0000                         189          DC    AL2(0)             LENGTH                                01070000
                                    190 *                                                                       01080000
                                    191 *                                                                       01090000
000190                      001C8   192          ORG   ,                  RESTORE LOC TO HIGHEST                01100000
                                    193 *                                                                       01110000
                                    194 **********************************************************************  01120000
                                    195 **********************************************************************  01130000
                                    196 ** SECOND CARD OF OUR IPL DECK                                          01140000
                                    197 **    IT CONTAINS THREE CCW'S                                           01150000
                                    198 **    THESE CCW'S READ THE THREE CARDS CONTAINING EXECUTABLE CODE       01160000
                                    199 **********************************************************************  01170000
                                    200 **********************************************************************  01180000
0001C8                              201          DS    0D                                                       01190000
0001C8 0000000000000000             202 CARD1    DC    80XL1'00'          SECOND IPL CARD                       01200000
000218                      001C8   203          ORG   CARD1                                                    01210000
                                    204 *                                                                       01220000
                                    205 **********************************************************************  01230000
                                    206 *        CCW                                                            01240000
                                    207 **********************************************************************  01250000
                                    208 *                                                                       01260000
0001C8 02                           209 CCW3     DC    X'02'              READ                                  01270000
0001C9 002050                       210          DC    AL3(CLA+80)        ADDRESS FOR DATA                      01280000
0001CC 60                           211          DC    X'60'              CC + SLI                              01290000
0001CD 00                           212          DC    X'00'                                                    01300000
0001CE 0050                         213          DC    AL2(80)            LENGTH                                01310000
                                    214 *                                                                       01320000
                                    215 **********************************************************************  01330000
                                    216 *        CCW                                                            01340000
                                    217 **********************************************************************  01350000
                                    218 *                                                                       01360000
0001D0 02                           219 CCW4     DC    X'02'              READ                                  01370000
0001D1 0020A0                       220          DC    AL3(CLA+160)       ADDRESS FOR DATA                      01380000
0001D4 60                           221          DC    X'60'              CC + SLI                              01390000
0001D5 00                           222          DC    X'00'                                                    01400000
0001D6 0050                         223          DC    AL2(80)            LENGTH                                01410000
                                    224 *                                                                       01420000
                                    225 **********************************************************************  01430000
                                    226 *        CCW                                                            01440000
                                    227 **********************************************************************  01450000
                                    228 *                                                                       01460000                                                                                                               PAGE    6

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

0001D8 02                           229 CCW5     DC    X'02'              READ                                  01470000
0001D9 0020F0                       230          DC    AL3(CLA+240)       ADDRESS FOR DATA                      01480000
0001DC 20                           231          DC    X'20'              SLI                                   01490000
0001DD 00                           232          DC    X'00'                                                    01500000
0001DE 0050                         233          DC    AL2(80)            LENGTH                                01510000
                                    234 *                                                                       01520000
                                    235 *                                                                       01530000
                                    236 *                                                                       01540000
                                    237 *                                                                       01550000
0001E0                      00218   238          ORG   ,                  RESTORE LOC TO HIGHEST                01560000
                                    239 *                                                                       01570000
                                    240 **********************************************************************  01580000
                                    241 **********************************************************************  01590000
                                    242 ** FOLLOWING CARDS CONTAIN THE EXECUTABLE PROGRAM                       01600000
                                    243 **********************************************************************  01610000
                                    244 **********************************************************************  01620000
000218                              245          DS    0D                                                       01630000
000218                              246 CARD2    DS    0X                 SECOND IPL CARD                       01640000
                                    247 **********************************************************************  01650000
                                    248 *        EXECUTABLE PROGRAM BEINGS HERE                                 01660000
                                    249 **********************************************************************  01670000
000218                              250 BEGIN    DS    0H                                                       01680000
000218 05A0                         251          BALR  R10,0              ESTABLISH BASE REG                    01690000
                            0021A   252          USING *,R10                                                    01700000
                                    253 *                                                                       01710000
                                    254 **********************************************************************  01720000
                                    255 *        GET DEVICE PHYSICAL ADDRESSES R3=CARD READER                   01730000
                                    256 **********************************************************************  01740000
                                    257 *                                                                       01750000
00021A 1F33                         258          SLR   R3,R3              CLEAR R3                              01760000
00021C BF33 0002      00002         259          ICM   R3,B'0011',2       GET IPL DEVICE (CARD RDR)             01770000
                                    260 *                                                                       01780000
                                    261 **********************************************************************  01790000
                                    262 *        PUT THE I/O BUFFER ADDRESS INTO THE CCW'S                      01800000
                                    263 **********************************************************************  01810000
                                    264 *                                                                       01820000
000220 4110 A0EE      00308         265          LA    R1,RDBUF           READ BUFFER                           01830000
000224 BE17 A097      002B1         266          STCM  R1,B'0111',RDCCW+1 ADDRESS TO READ CCW                   01840000
                                    267 *                                                                       01850000
                                    268 **********************************************************************  01860000
                                    269 *        PROGRAM MAIN LOOP                                              01870000
                                    270 **********************************************************************  01880000
                                    271 *                                                                       01890000
000228                              272 RDLP     DS    0H                                                       01900000                                                                                                               PAGE    7

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

000228 4110 A096      002B0         273          LA    R1,RDCCW           GET ADDR OF READ CCW                  01910000
00022C 5010 0048      00048         274          ST    R1,72              PUT INTO CAW                          01920000
                                    275 *                                                                       01930000
000230 9C00 3000      00000         276          SIO   0(R3)              ISSUE READ                            01940000
000234 4770 A0A8      002C2         277          BNZ   ERR1               BRANCH IF ERROR                       01950000
                                    278 *                                                                       01960000
                                    279 **********************************************************************  01970000
                                    280 *        WAIT FOR READ I/O TO COMPLETE                                  01980000
                                    281 **********************************************************************  01990000
                                    282 *                                                                       02000000
000238                              283 RDTIO    DS    0H                                                       02010000
000238 9D00 3000      00000         284          TIO   0(R3)              CHECK FOR I/O COMPLETION              02020000
00023C 4780 A02E      00248         285          BZ    LOADIT             GO PRINT IF GOOD                      02030000
000240 4710 A0AC      002C6         286          BC    1,ERR2             BRAHCH IF ERR                         02040000
000244 47F0 A01E      00238         287          B     RDTIO              WAIT AGAIN                            02050000
                                    288 *                                                                       02060000
                                    289 **********************************************************************  02070000
                                    290 *        CHECK FOR SUCCESSFUL COMPLETION OF I/O                         02080000
                                    291 *                                                                       02090000
                                    292 *        EXPECT ONLY CHANNEL END + DEVICE END                           02100000
                                    293 *                                                                       02110000
                                    294 *        ANYTHING ELSE WE QUIT                                          02120000
                                    295 *                                                                       02130000
                                    296 **********************************************************************  02140000
                                    297 *                                                                       02150000
000248                              298 LOADIT   DS    0H                                                       02160000
000248 D501 A0D6 0044 002F0 00044   299          CLC   CEDE,68            CE+DE                                 02170000
00024E 4770 A09E      002B8         300          BNE   ERR0               NO - QUIT                             02180000
                                    301 *                                                                       02190000
                                    302 **********************************************************************  02200000
                                    303 *        CHECK TYPE OF CARD JUST READ                                   02210000
                                    304 **********************************************************************  02220000
                                    305 *                                                                       02230000
000252 9502 A0EE      00308         306          CLI   RDBUF,X'02'        OBJECT DECK CARD?                     02240000
000256 4770 A0B0      002CA         307          BNE   ERR3               NO - ERROR                            02250000
                                    308 *                                                                       02260000
00025A D502 A0D8 A0EF 002F2 00309   309          CLC   K@SYM,RDBUF+1      SYM RECORD                            02270000
000260 4780 A00E      00228         310          BE    RDLP               YES - IGNORE IT                       02280000
                                    311 *                                                                       02290000
000264 D502 A0DE A0EF 002F8 00309   312          CLC   K@ESD,RDBUF+1      ESD RECORD                            02300000
00026A 4780 A00E      00228         313          BE    RDLP               YES - IGNORE IT                       02310000
                                    314 *                                                                       02320000
00026E D502 A0DB A0EF 002F5 00309   315          CLC   K@RLD,RDBUF+1      RLD RECORD                            02330000
000274 4780 A00E      00228         316          BE    RDLP               YES - IGNORE IT                       02340000                                                                                                               PAGE    8

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

                                    317 *                                                                       02350000
000278 D502 A0E1 A0EF 002FB 00309   318          CLC   K@TXT,RDBUF+1      TXT RECORD                            02360000
00027E 4780 A076      00290         319          BE    LDTXT              YES - IGNORE IT                       02370000
                                    320 *                                                                       02380000
000282 D502 A0E4 A0EF 002FE 00309   321          CLC   K@END,RDBUF+1      END RECORD                            02390000
000288 4780 A090      002AA         322          BE    LDEND              YES - IGNORE IT                       02400000
                                    323 *                                                                       02410000
00028C 47F0 A0B0      002CA         324          B     ERR3               INVALID CARD TYPE                     02420000
                                    325 *                                                                       02430000
                                    326 **********************************************************************  02440000
                                    327 *        LOAD TEXT RECORD CONTENTS INTO MEMORY                          02450000
                                    328 **********************************************************************  02460000
                                    329 *                                                                       02470000
000290                              330 LDTXT    DS    0H                                                       02480000
000290 1F44                         331          SLR   R4,R4              ZERO R4                               02490000
000292 BF47 A0F3      0030D         332          ICM   R4,B'0111',RDBUF+5 GET 24 BIT ADDDRESS FOR DATA          02500000
000296 4850 A0F8      00312         333          LH    R5,RDBUF+10        GET DATA LENGTH                       02510000
00029A 0650                         334          BCTR  R5,0               ADJUST FOR EXECUTE                    02520000
00029C 4450 A08A      002A4         335          EX    R5,LDMVC           MOVE THE DATA                         02530000
0002A0 47F0 A00E      00228         336          B     RDLP               GET NEXT CARD                         02540000
                                    337 *                                                                       02550000
0002A4 D200 4000 A0FE 00000 00318   338 LDMVC    MVC   0(1,R4),RDBUF+16   EXECUTED MOVE                         02560000
                                    339 *                                                                       02570000
                                    340 *                                                                       02580000
                                    341 **********************************************************************  02590000
                                    342 *        PROCESS END CARD                                               02600000
                                    343 **********************************************************************  02610000
                                    344 *                                                                       02620000
0002AA                              345 LDEND    DS    0H                                                       02630000
0002AA 8200 0000      00000         346          LPSW  0                  LOAD PSW CONTAINED AT LOCATION ZERO   02640000
                                    347 *                                                                       02650000
                                    348 *                                                                       02660000
                                    349 **********************************************************************  02670000
                                    350 *        CCW'S TO READ AND PRINT                                        02680000
                                    351 **********************************************************************  02690000
                                    352 *                                                                       02700000
                                    353 *                                                                       02710000
0002B0                              354          DS    0D                                                       02720000
0002B0 0200000000000050             355 RDCCW    DC    X'02',AL3(0),X'0000',AL2(80)                             02730000
                                    356 *                                                                       02740000
                                    357 *                                                                       02750000
                                    358 **********************************************************************  02760000
                                    359 *        ERROR ROUTINES                                                 02770000
                                    360 *           LOAD PSW WITH WAIT BIT SET TO ONE                           02780000                                                                                                               PAGE    9

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

                                    361 **********************************************************************  02790000
                                    362 *                                                                       02800000
                                    363 *                                                                       02810000
0002B8 D201 A0BC 0044 002D6 00044   364 ERR0     MVC   PSWERR0+6(2),68                                          02820000
0002BE 8200 A0B6      002D0         365          LPSW  PSWERR0                                                  02830000
0002C2 8200 A0BE      002D8         366 ERR1     LPSW  PSWERR1                                                  02840000
0002C6 8200 A0C6      002E0         367 ERR2     LPSW  PSWERR2                                                  02850000
0002CA 8200 A0CE      002E8         368 ERR3     LPSW  PSWERR3                                                  02860000
                                    369 *                                                                       02870000
                                    370 *                                                                       02880000
                                    371 **********************************************************************  02890000
                                    372 *        WAIT PSW'S                                                     02900000
                                    373 **********************************************************************  02910000
                                    374 *                                                                       02920000
                                    375 *                                                                       02930000
0002D0                              376          DS    0D                                                       02940000
0002D0 0002000000990000             377 PSWERR0  DC    X'00',X'02',X'0000',X'00',X'990000'                      02950000
0002D8 0002000000EE0001             378 PSWERR1  DC    X'00',X'02',X'0000',X'00',X'EE0001'                      02960000
0002E0 0002000000EE0002             379 PSWERR2  DC    X'00',X'02',X'0000',X'00',X'EE0002'                      02970000
0002E8 0002000000EE0003             380 PSWERR3  DC    X'00',X'02',X'0000',X'00',X'EE0003'                      02980000
                                    381 *                                                                       02990000
                                    382 *                                                                       03000000
                                    383 **********************************************************************  03010000
                                    384 *        CONSTANTS                                                      03020000
                                    385 **********************************************************************  03030000
                                    386 *                                                                       03040000
                                    387 *                                                                       03050000
0002F0 0C00                         388 CEDE     DC    X'0C00'            CHANNEL END + DEVICE END              03060000
                                    389 *                                                                       03070000
                                    390 *                                                                       03080000
0002F2 E2E8D4                       391 K@SYM    DC    C'SYM'                                                   03090000
0002F5 D9D3C4                       392 K@RLD    DC    C'RLD'                                                   03100000
0002F8 C5E2C4                       393 K@ESD    DC    C'ESD'                                                   03110000
0002FB E3E7E3                       394 K@TXT    DC    C'TXT'                                                   03120000
0002FE C5D5C4                       395 K@END    DC    C'END'                                                   03130000
                                    396 *                                                                       03140000
                                    397 *                                                                       03150000
                                    398 **********************************************************************  03160000
                                    399 *        I/O BUFFER AREA                                                03170000
                                    400 **********************************************************************  03180000
                                    401 *                                                                       03190000
                                    402 *                                                                       03200000
                            000E9   403 CARD2LEN EQU   *-CARD2                                                  03210000
                            00003   404 CARD2CNT EQU   ((CARD2LEN+79)/80)                                       03220000                                                                                                               PAGE   10

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 12.09 11/11/11

000308                              405 RDBUF    DS    0D            I/O BUFFER                                 03230000
000308                      00308   406          ORG   ,                                                        03240000
                                    407 *                                                                       03250000
                                    408 *                                                                       03260000
                                    409 **********************************************************************  03270000
                                    410 *        BUFFER AREA TO MAKE SURE WE HAVE AT LEAST 80 BYTES FOR THE     03280000
                                    411 *        LAST CARD WE WRINTE                                            03290000
                                    412 **********************************************************************  03300000
                                    413 *                                                                       03310000
                                    414 *                                                                       03320000
000308                              415          DS    CL80          *** EXTRA BUFFER AREA ***                  03330000
                                    416 *                                                                       03340000
                                    417 *                                                                       03350000
                                    418 **********************************************************************  03360000
                                    419 *        REGISTER EQUATES                                               03370000
                                    420 **********************************************************************  03380000
                                    421 *                                                                       03390000
                                    422 *                                                                       03400000
                            00000   423 R0       EQU   0                                                        03410000
                            00001   424 R1       EQU   1                                                        03420000
                            00002   425 R2       EQU   2                                                        03430000
                            00003   426 R3       EQU   3                                                        03440000
                            00004   427 R4       EQU   4                                                        03450000
                            00005   428 R5       EQU   5                                                        03460000
                            00006   429 R6       EQU   6                                                        03470000
                            00007   430 R7       EQU   7                                                        03480000
                            00008   431 R8       EQU   8                                                        03490000
                            00009   432 R9       EQU   9                                                        03500000
                            0000A   433 R10      EQU   10                                                       03510000
                            0000B   434 R11      EQU   11                                                       03520000
                            0000C   435 R12      EQU   12                                                       03530000
                            0000D   436 R13      EQU   13                                                       03540000
                            0000E   437 R14      EQU   14                                                       03550000
                            0000F   438 R15      EQU   15                                                       03560000
                                    439 *                                                                       03570000
                                    440 *                                                                       03580000
                                    441          END   ,                                                        03590000                                                  RELOCATION DICTIONARY                                        PAGE   11

POS.ID   REL.ID   FLAGS   ADDRESS                                                                ASM 0201 12.09 11/11/11

 0001     0001      08     000019
 0001     0001      08     000069
                                                  CROSS-REFERENCE                                              PAGE   12

SYMBOL    LEN   VALUE   DEFN    REFERENCES                                                       ASM 0201 12.09 11/11/11

ABSLOAD  00001 00000000 00009  00012
CARD0    00001 00000178 00158  00031 00159
CARD1    00001 000001C8 00202  00039 00203
CARD2    00001 00000218 00246  00047 00052 00057 00403
CARD2LEN 00001 000000E9 00403  00404
CEDE     00002 000002F0 00388  00299
CLA      00001 00002000 00147  00169 00176 00186 00210 00220 00230
ERR0     00006 000002B8 00364  00300
ERR1     00004 000002C2 00366  00277
ERR2     00004 000002C6 00367  00286
ERR3     00004 000002CA 00368  00307 00324
K@END    00003 000002FE 00395  00321
K@ESD    00003 000002F8 00393  00312
K@RLD    00003 000002F5 00392  00315
K@SYM    00003 000002F2 00391  00309
K@TXT    00003 000002FB 00394  00318
LDEND    00002 000002AA 00345  00322
LDMVC    00006 000002A4 00338  00335
LDTXT    00002 00000290 00330  00319
LOADIT   00002 00000248 00298  00285
PSWERR0  00001 000002D0 00377  00364 00365
PSWERR1  00001 000002D8 00378  00366
PSWERR2  00001 000002E0 00379  00367
PSWERR3  00001 000002E8 00380  00368
PUNCH    00004 00000118 00091  00024 00030 00038 00046 00051 00056 00070
RDBUF    00008 00000308 00405  00265 00306 00309 00312 00315 00318 00321 00332 00333 00338
RDCCW    00001 000002B0 00355  00266 00273
RDLP     00002 00000228 00272  00310 00313 00316 00336
RDTIO    00002 00000238 00283  00287
R1       00001 00000001 00424  00014 00015 00016 00017 00265 00266 00273 00274
R10      00001 0000000A 00433  00251 00252
R12      00001 0000000C 00435  00010 00011 00012 00075 00144
R13      00001 0000000D 00436  00010 00015 00016 00017 00074 00074 00075
R14      00001 0000000E 00437  00010 00075 00077
R15      00001 0000000F 00438  00011 00076 00076
R3       00001 00000003 00426  00258 00258 00259 00276 00284
R4       00001 00000004 00427  00331 00331 00332 00338
R5       00001 00000005 00428  00333 00334 00335
SAVEA    00004 000000D0 00083  00014                                                  ASSEMBLER DIAGNOSTICS AND STATISTICS                         PAGE   13

                                                                                                 ASM 0201 12.09 11/11/11

NO STATEMENTS FLAGGED IN THIS ASSEMBLY
HIGHEST SEVERITY WAS    0
OPTIONS FOR THIS ASSEMBLY
  ALIGN, ALOGIC, BUFSIZE(STD), DECK, ESD, FLAG(0), LINECOUNT(44), LIST, NOMCALL, YFLAG, WORKSIZE(2097152)
  NOMLOGIC, NONUMBER, NOOBJECT, NORENT, RLD, NOSTMT, NOLIBMAC, NOTERMINAL, NOTEST, XREF(SHORT)
  SYSPARM()
WORK FILE BUFFER SIZE/NUMBER =19066/ 1
TOTAL RECORDS READ FROM SYSTEM INPUT        359
TOTAL RECORDS READ FROM SYSTEM LIBRARY     3144
TOTAL RECORDS PUNCHED                        19
TOTAL RECORDS PRINTED                       469

[Next – Absolute Loader Description]

Absolute Object Deck Loader

Now that we have managed to write a stand-alone program we can IPL and execute it would be nice to not have to write it as a program-in-a-program.  Although it gets the job done it is not as straight forward as simply writing a program, assembling it, dropping the resulting object deck in our card reader and hitting IPL.

By building a simple object deck loader we can do just that.  Our object deck loader will be a few cards containing a stand alone program that will IPL and then read an object deck from the card reader.  It will load the object deck into memory and then transfer execution when all cards have been read.

We will write an absolute loader.  Usually we think of a relocating loader that will allow us to load our program into any memory address and handle the necessary work to update relocatable addresses.  Our loader will not attempt to update relocatable addresses.

Since we want to use the object deck created by the assembler we need to understand what types of records make up an object deck.  There are five types of cards or records that may be found in an object deck.  For our simple loader we will only need to be concerned with just two of these.  We can safely ignore the other three types.

Object deck records always start with a x’02’ in column one followed by a three character code that identifies the type of record.  These types are SYM for symbolic debugging information, ESD for external sysbols, TXT for text records, RLD for relocatable symbol information and END for the end record.

We will ignore everything except TXT and END records.

The TXT record has the following layout:

  X     '02'     Object Deck Record
  CL3   'TXT'    Text Record
  C     blank
  XL3            24 bit address of first byte of text data
  CL2   blank
  XL2            Number of byes of text data
  CL2   blank
  XL2            ESD identifier of SD for control section
  XL56           Variable Text Data

The END record data we are concerned with is:

  X     x'02'    Object Deck Record
  CL3   'END'    End Record
  C     blank
  XL3            24 bit address of entry point

The logic of the loader is pretty simple. We start by reading a card.  We then verify it is an object deck record (x’02’ in the first byte).  We then check to see if it is a TXT or END card.  If it is anything else we ignore it and read the next card.

For TXT cards we move the number of bytes specified in the length field from the text data area to the main memory address specified in the 24 bit address field.

When we encounter an END card we branch to the location contained in the entry point address.

If we encounter any errors we can load a wait state PSW to signal an error condition.

[ Next – Absolute Loader Assembly Listing]