søndag den 27. september 2015

How the assembler works (6)

Checking for reentrant code

I wrote about how you could make your program reentrant some blog posts ago. The assembler can actually help you check for non-reentrant code.
          PRINT GEN           
 PGM4     RSECT               
 PGM4     RMODE ANY           
          ENTRY PGM4          
          BASR  11,0          
          USING *,11          
          MVC   NAME,=CL8'PGM4'
          B     RETURN        
 NAME     DS    CL8           
 RETURN   RETURN RC=0         
          LTORG               
    
      END                  
 PGM4     BINDER REUS=RENT    
          END
Non-reentrant code
All you have to do is replace CSECT with RSECT on the first line and tell the Linkage Editor, that the module must be Link Edited to reentrant.

  Loc  Object Code    Addr1 Addr2  Stmt   Source Statement              
                                      1          PRINT GEN              
000000                00000 00028     2 PGM4     RSECT                  
                                      3 PGM4     RMODE ANY              
                                      4          ENTRY PGM4             
000000 0DB0                           5          BASR  11,0             
                 R:B  00002           6          USING *,11             
000002 D207 B00A B01E 0000C 00020     7          MVC   NAME,=CL8'PGM4'  
** ASMA036W Reentrant check failed                                      
** ASMA435I Record 7 in EXJEL.EXJEL004.JOB07544.D0000101.? on volume:   
000008 47F0 B012            00014     8          B     RETURN           
00000C                                9 NAME     DS    CL8              
                                     10 RETURN   RETURN RC=0            
000014                               12+RETURN   DS    0H               
000014 41F0 0000            00000    13+         LA    15,0(0,0)        
000018 07FE                          14+         BR    14               
000020                               15          LTORG                  
000020 D7C7D4F440404040              16                =CL8'PGM4'       
                                     17          END                    

Assembler list with reentrant error.
The result is an error where you do not respect the rules for reentrant coding:
** ASMA036W Reentrant check failed

Ingen kommentarer:

Send en kommentar