tirsdag den 22. september 2015

How the assembler works (5)

How to avoid Linkage Editor SYSIN

You have probably tried to make your own JCL to assemble and link-edit your program. It can be a little annoying to define the sysin to the Linkage Editor / Binder, either as a member in a PDS or as SYSIN as below.
//LNK.SYSIN DD *                            
  SETOPT PARM(LET,LIST,XREF,NCAL,REUS=RENT)
  MODE AMODE(31),RMODE(ANY)                
  NAME PGM4(R)                             
/*                                          
Linkage Editor SYSIN
I will now show you a macro that will do it for you. You can either make a new macro, as I did, or put it into the previous PROGRAM macro. That is up to you.
Actually, you do not need a macro. You just need to issue some PUNCH statements at the start or the end of your program. PUNCH writes a record on the same DD-card as the assembler writes the object deck. I have made a macro in order to hide what is done and make it easier for you.
        MACRO                                               
&PGM     BINDER &AMODE=31,&RMODE=ANY,&REUS=SERIAL            
.*************************************                       
.** PUNCH SYSIN TO THE BINDER       **                       
.*************************************                       
        PUNCH ' SETOPT PARM(LET,LIST,XREF,NCAL,REUS=&REUS.)'
        PUNCH ' MODE AMODE(&AMODE.),RMODE(&RMODE.)'         
        PUNCH ' NAME &PGM.(R)'                              
        MEND                                                
BINDER macro
The BINDER macro takes some parameters so you can change some of the Binder sysin. They have some very common default values, so you can probably do with:
[program name]  BINDER
Take a look at this very simple program:
//[userid]004 JOB 1,[userid],CLASS=8,MSGCLASS=Z,MSGLEVEL=(1,1),
//        NOTIFY=&SYSUID,                                  
//        REGION=0M                                        
//PROCLIB  JCLLIB ORDER=[userid].SRC.JCL                      
//ASMLNK  EXEC ASMLNK                                      
//ASM.SYSIN DD *                                           
PGM4     CSECT                                             
PGM4     RMODE ANY                                         
        ENTRY PGM4                                        
        DC    CL8'PGM4'                                   
        END                                               
PGM4     BINDER                                            
        END                                               
/*                                                         
//                                                         
Source of program with Binder sysin
That is all you need. There is a pitfall that annoyed me a while. The BINDER macro is in a separate source program. That is why you must type “END” after your program and then the BINDER macro and end that with an “END” too. It is called “Batch Assembling”. That protects the PUNCH records to intertwine with the object code of your program.
 Loc  Object Code    Addr1 Addr2  Stmt   Source Statement      
000000                00000 00008     1 PGM4     CSECT          
                                     2 PGM4     RMODE ANY      
                                     3          ENTRY PGM4     
000000 D7C7D4F440404040               4          DC    CL8'PGM4'
                                     5          END            
Loc  Object Code    Addr1 Addr2  Stmt   Source Statement                     
                                   1 PGM4     BINDER                        
                                   2+         PUNCH ' SETOPT PARM(LET,LIST,XREF,NCAL,REUS=SERIAL)'
                                   3+         PUNCH ' MODE AMODE(31),RMODE(ANY)'
                                   4+         PUNCH ' NAME PGM4(R)'         
                                   5          END
Assembler List of the two “programs”
ESD      ..  ..PGM4    ........                    
TXT ...  ..  ..PGM4                                
END                            1569623400 010615265
SETOPT PARM(LET,LIST,XREF,NCAL,REUS=SERIAL)        
MODE AMODE(31),RMODE(ANY)                          
NAME PGM4(R)                                       
Object code to the Linkage Editor / Binder
The first three lines of the example above are the object code from the program that starts with ESD and ends with END as any object code. After that come all the sysin parameters from your PUNCH.
The last figure is the JCL-procedure you can use. There are of course no SYSIN in the LNK step.
//ASMLNK   PROC                                              
//ASM      EXEC PGM=ASMA90,PARM='DECK,OBJECT'                
//SYSLIB   DD DISP=SHR,DSN=SYS1.MACLIB                       
//         DD DISP=SHR,DSN=[userid].SRC.ASM                     
//SYSUT1   DD DSN=&&TEMP1,UNIT=SYSDA,SPACE=(1700,(800,400))  
//SYSPRINT DD SYSOUT=*,DCB=BLKSIZE=1089                      
//SYSPUNCH DD SYSOUT=*                                       
//SYSLIN   DD DSN=&&OBJ,UNIT=SYSDA,SPACE=(80,(200,50)),      
//            DISP=(MOD,PASS),DCB=BLKSIZE=3200               
//SYSIN    DD DUMMY                                          
//LNK      EXEC PGM=HEWL,                                    
//            COND=(0,NE,ASM)                                
//SYSLIN   DD DSN=&&OBJ,DISP=(OLD,DELETE)                    
//SYSLMOD  DD DSN=[userid].LOADLIB,DISP=SHR                     
//SYSUT1   DD DSN=&&TEMP2,SPACE=(1024,(50,20))               
//SYSPRINT DD SYSOUT=*,DCB=(RECFM=FB,LRECL=121,BLKSIZE=1210)
//         PEND                                              
Procedure for assembler and binder

The parm to ASMA90 is ‘DECK,OBJECT’ which makes the assembler write exactly the same object code and punch to both SYSLIN and SYSPUNCH. You can NOT direct PUNCH to one DD-card and the object deck to another.

Ingen kommentarer:

Send en kommentar