IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Assembler: A simple re-entrant program. Help needed.


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Thu Apr 07, 2011 4:42 pm
Reply with quote

Hi,

This is my first attempt at re-entrant coding. The idea behind this program is to just open a PS file and get the data out of it.

Code:

TEST0016 CSECT                                         
         YREGS                                         
         BAKR  R14,0                                   
         LR    R7,R15                                 
         USING TEST0016,R7                             
*                                                     
         GETMAIN R,LV=WORKLEN                         
         LR    R4,R1                                   
         USING WORKAR,R4                               
         MVC   IN(SIZE_INDCB),INDCB                   
         MVC   OPENWK(SIZE_OPN),OPENS                 
         MVC   CLOSWK(SIZE_CLO),CLOSES                 
         GETMAIN R,LV=80                               
         LR    R3,R1                                   
         OPEN  (IN),MF=(E,OPENWK)                     
*                                                     
LOOP1    DS    0H                                     
         GET   IN,(3)                                 
         B     LOOP1                                   
DONE     CLOSE (IN),MF=(E,CLOSWK)                     
         FREEMAIN R,LV=80,A=(R3)                       
         FREEMAIN R,LV=WORKLEN,A=(R4)                 
         PR                                           
INDCB    DCB DSORG=PS,MACRF=GM,DCBE=IN_DCBE,DDNAME=INDD
SIZE_INDCB EQU *-INDCB                                 
IN_DCBE  DCBE EODAD=DONE,RMODE31=BUFF                 
OPENS    OPEN (,,),MF=L                               
SIZE_OPN EQU *-OPENS                                   
CLOSES   CLOSE (,,),MF=L                               
SIZE_CLO EQU *-CLOSES                                 
WORKAR   DSECT                                         
IN       DS XL(SIZE_INDCB)                             
OPENWK   DS XL(SIZE_OPN)                               
CLOSWK   DS XL(SIZE_CLO)                               
WORKLEN  EQU *-WORKAR                                 
         END                                           


This is giving me a S0C4 error saying as below.

Code:

********************************************************************************
***********************  P O I N T   O F   F A I L U R E  **********************
********************************************************************************
                                                                               
This supervisor call (SVC) in CSECT TEST0016 resulted in the S0C4 abend.       
                                                                               
NOTE: Source code information for CSECT TEST0016 could not be presented because
      no compiler listing or side-file data sets were provided.                 
                                                                               
Load Module Name. . . . . . : M11130.SYSASM.LOADLIB(TEST0016)                   
  At Address. . . . . . . . : 00007EC0                                         
  Load Module Length. . . . : X'140'                                           
  Link-Edit Date and Time . : 2011/04/07  11:57:53                             
                                                                               
CSECT Name. . . . . . . . . : TEST0016                                         
  At Address. . . . . . . . : 00007EC0 (Module TEST0016 offset X'0')           
  CSECT Length. . . . . . . : X'13C'                                           
  CSECT Language. . . . . . : Assembler (Compiled using High Level Assembler V1
                              R6 M0 on 2011/04/07)                             
                                                                               
Machine Instruction . . . . : 0A13          SVC   19 (OPEN)                     
  At Address. . . . . . . . : 00007F0A (CSECT TEST0016 offset X'4A')           
  AMODE . . . . . . . . . . : 24                                               
                                                                               
Instructions around point of failure:                                           
                                                                                  Offset Hex            Instruction                                       
  ------ -------------- ---------------------------------------------------
     -32 D25F 4000 7094 MVC   0(96,R4),148(R7)                             
     -2C D207 4060 712C MVC   96(8,R4),300(R7)                             
     -26 D207 4068 7134 MVC   104(8,R4),308(R7)                           
     -20 4100 0050      LA    R0,80                                       
     -1C 4510 7032      BAL   R1,50(,R7)                                   
     -18 0A0A           SVC   10        (FREEMAIN GETMAIN)                 
     -16 1831           LR    R3,R1                                       
     -14 4110 4060      LA    R1,96(,R4)                                   
     -10 43E1 0000      IC    R14,0(R1)                                   
      -C 4100 4000      LA    R0,0(,R4)                                   
      -8 5001 0000      ST    R0,0(R1)                                     
      -4 42E1 0000      STC   R14,0(R1)                                   
   ***** 0A13           SVC   19        (OPEN)                             
      +2 4110 4000      LA    R1,0(,R4)                                   
      +6 1803           LR    R0,R3                                       
      +8 1FFF           SLR   R15,R15                                     
      +A BFF7 1031      ICM   R15,7,49(R1)                                 
      +E 05EF           BALR  R14,R15                                     
     +10 47F0 704C      BC    15,76(,R7)                                   
     +14 4110 4068      LA    R1,104(,R4)                                 
                                                                           
Program Status Word (PSW) . : 078D0000 00007F0C                           
                                                                           
General Purpose Registers:                             
  R0:  00006EF0 (4368 bytes of storage addressable)     
  R1:  00006F50 (4272 bytes of storage addressable)     
  R2:  00000040 (1984 bytes of storage addressable)     
  R3:  00006EA0 (4448 bytes of storage addressable)     
  R4:  00006EF0 (4368 bytes of storage addressable)     
  R5:  009FF350 (3248 bytes of storage addressable)     
  R6:  009B5FE0 (303136 bytes of storage addressable)   
  R7:  00007EC0 (Module TEST0016 CSECT TEST0016 + X'0')
  R8:  009FC010 (16368 bytes of storage addressable)   
  R9:  009C7CC8 (230200 bytes of storage addressable)   
  R10: 00000000 (2048 bytes of storage addressable)     
  R11: 009FF350 (3248 bytes of storage addressable)     
  R12: 8802DCA2 (Module IEFSD060 + X'9CA2')             
  R13: 00006F60 (4256 bytes of storage addressable)     
  R14: 80FD8800 (151816192 bytes of storage addressable)
  R15: 00000000 (2048 bytes of storage addressable)     
                                                       
<H2> EVENT 2 OF 2: ABEND S0C4                                                   
                                                                               
Abend Code. . . . . . . . . : S0C4-X'4'                                         
Program-Interruption Code . : 0004 (Protection Exception)                       
                              An attempt was made to access a protected storage
                              location using an incorrect storage access key.   
                                                                               
Load Module Name. . . . . . : IFG019RA (In Link Pack Area)                     
  At Address. . . . . . . . : 00D2C000                                         
  Load Module Length. . . . : X'4CC8'                                           
                                                                               
Machine Instruction . . . . : 0E02          MVCL  R0,R2                         
  At Address. . . . . . . . : 00D2DF28 (Module IFG019RA offset X'1F28')         
  AMODE . . . . . . . . . . : 31                                               
  Failing Operand . . . . . : Second operand                                   
  First Operand Address . . : 00000028 (2008 bytes of storage addressable)     
  First Operand Length. . . : 12                                               
  First Operand Storage . . : 7FFFF000 7FFFF000 00000000   *".0.".0.....*       
  Second Operand Address. . : 009AFD08 (Storage invalid)                       
  Second Operand Length . . : 12                                               
  Operands are shown as at the time of interruption.                           
                                                                               
Additional instructions around event offset:                                   
                                                                               
  Offset Hex            Instruction                                             
  ------ -------------- --------------------------------------------------------
     -30 B20A 0050      SPKA  80                                               
     -2C 9601 2030      OI    48(R2),1                                         
     -28 D201 201A 41E0 MVC   26(2,R2),480(R4)                                 
     -22 47F0 5E78      BC    15,3704(,R5)                                     
     -1E 43B0 420E      IC    R11,526(,R4)                                     
     -1A B20A B000      SPKA  0(R11)                                           
     -16 5800 4238      L     R0,568(,R4)                                       
     -12 5820 423C      L     R2,572(,R4)                                       
      -E 4A00 4240      AH    R0,576(,R4)                                       
      -A 4A20 4240      AH    R2,576(,R4)                                       
      -6 4810 4242      LH    R1,578(,R4)                             
      -2 1831           LR    R3,R1                                   
   ***** 0E02           MVCL  R0,R2                                   
      +2 B20A 0050      SPKA  80                                     
      +6 47F0 5E78      BC    15,3704(,R5)                           
      +A 43C0 420E      IC    R12,526(,R4)                           
      +E 58B0 4238      L     R11,568(,R4)                           
     +12 B20A C000      SPKA  0(R12)                                 
     +16 9110 B030      TM    48(R11),16                             
     +1A 47E0 5E32      BC    14,3634(,R5)                           
                                                                     
Program Status Word (PSW) . : 078C2000 80D2DF2A                       
                                                                     
General Purpose Registers:                                           
  R0:  00000028 (2008 bytes of storage addressable)                   
  R1:  0000000C (2036 bytes of storage addressable)                   
  R2:  009AFD08 (Storage invalid)                                     
  R3:  0000000C (2036 bytes of storage addressable)                   
  R4:  009AFD60 (Storage invalid)                                     
  R5:  00D2D120 (Module IFG019RA + X'1120')                           
  R6:  009B0698 (Storage invalid)                                     
  R7:  C0000010 (Storage invalid)                                     
  R8:  009B075C (Storage invalid)                                     
  R9:  009B6014 (303084 bytes of storage addressable)                 
  R10: 00D008DA (Module IGC0001I + X'18DA')                           
  R11: 009B0780 (Storage invalid)                                     
  R12: 009B076C (Storage invalid)                                     
  R13: 009B03F8 (Storage invalid)                                     
  R14: 00D00A24 (Module IGC0001I + X'1A24')                           
  R15: 009B06B8 (Storage invalid)


I came across the concept of re-entrant programs in assembler couple of weeks back. Ever since, I am trying to get myself accustomed to all the norms of re-entrant programs. I am sure this is something that experienced programmers would do, but I feel it would be real good if such programming technique could be made as a habit. I could not see any drawbacks in such a technique. I request your assitance to get me introduced to this concept of programming.

Thank you... icon_smile.gif
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Apr 07, 2011 5:08 pm
Reply with quote

Try changing -

Code:

BAKR  R14,0 

to -

Code:

BALR  R15,0 


And -
Code:

USING TEST0016,R7 

to -

Code:

USING *,R7

and see if this makes a difference.

Also, before the BALR, add -

Code:

SAVE (14,12)             

And, substitute -

Code:

PR

with -

Code:

RETURN (14,12),RC=(15)   

You've omitted allocating a reentrant area for your 18-word RSA (Register Save Area), which is standard practice, possibly due to the misinterpretation of BAKR.

Bill
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Thu Apr 07, 2011 10:11 pm
Reply with quote

Also, place an LTORG before (at a suitable place)
Code:
WORKAR   DSECT

otherwise if literals are used in the program later then they will, by default, be added after the end of the program and will be addressed by R4 because of
Code:
USING WORKAR,R4

And this may produce unpredictable results at runtime
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 08, 2011 7:20 am
Reply with quote

Literals will be based off R7, which is the CSECT Base-Register.

Place the LTORG directly after -

Code:

WORKLEN  EQU *-WORKAR

and before the END statement.

HLASM ("ASMA90") recommends DSECT's be defined at the top of the program, before the CSECT, which is the opposite of the pre-HLASM "IEV90".

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top