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

S0C4 ON RETURN TO A PL1 PROGRAM FROM AN ASSEMBLER PROGRAM


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

New User


Joined: 11 Sep 2006
Posts: 33

PostPosted: Wed Mar 03, 2010 12:25 am
Reply with quote

Hello,
I'm new in Assembler and trying to learn the first steps, so sorry for any bad coding conventions or practices...
I'm trying to code an assembler routine to just receive parameters from a PL1 program, write them to a file and return. Just to learn how to pass parameters.
The problem is that, on return to the PL1 program, when I try to PUT the parameters to sysprint I get a SC04. If, in the PL1 program, I remark the PUT statement after calling the assembler program everything runs ok with RC=0. But if I try to PUT to sysprint the parameters I get S0C4.
I tried also moving with MVC some values to the parameters in the ASM program and then PUT them to sysprint in the PL1 program, but I get S0C1. Again, if I remark the PUT then it ends ok.
Any help on what's wrong with my code or how to pass parameters between PL1 and ASM would be really appreciated. In fact I already checked other posts with examples of ASM programs called from COBOL or PL1, and I don't find any difference with my code.

Code:
* THIS SAMPLE PROGRAM WILL READ PARAMS FROM A PL1 CALLER PGM.
*
* PARAMETERS
* R08 BASED
PDSECT   DSECT
PDDNAME  DS        CL8
POPERAT  DS        CL2
PRETCOD  DS        H
PRETMSG  DS        CL80
*
* START OF PROGRAM
TEST5    CSECT
         LR        12,15                     LOAD BASE ADDR OF MODULE
         USING     TEST5,12                  SET BASE REGISTER
         SAVE      (14,12)                   SAVE CALLER REGISTERS
         ST        13,BUFFSAVE+4             KEEP CALLER SAVE AREA
         L         8,0(,1)                   GET PARAM ADDRESS
         ST        8,BUFFR08                 KEEP PARAM ADDRESS
         LA        13,BUFFSAVE               SET OUR SAVE AREA ADDR
*
* OPEN SYSOUT DATASET TO PRINT TRACE MESSAGES
         OPEN      (OUTDCB,(OUTPUT))         OPEN OUTPUT FILE
*
* GET PARAMETERS AND PRINT THEM FOR TRACE
PARAMS   USING     PDSECT,8
         L         8,BUFFR08                 RESTORE REG08
         MVC       BUFFOUT(8),PARAMS.PDDNAME
         MVC       BUFFOUT+9(2),PARAMS.POPERAT
         PUT       OUTDCB,BUFFOUT
         L         8,BUFFR08
*
* END PGM ROUTINE
R_ENDPGM EQU       *
         MVC       BUFFOUT(80),=CL80'ENDPGM ROUTINE'
         PUT       OUTDCB,BUFFOUT
         CLOSE     (OUTDCB)                  CLOSE OUTPUT FILE
         L         13,BUFFSAVE+4             RESTORE CALLER AREA REG
         RETURN    (14,12),RC=0              RESTORE AND RETURN
*
*
*
* STORAGE AREA AND FILE DECLARES
*
* DCB DECLARATIONS
OUTDCB   DCB       DSORG=PS,MACRF=(PM),RECFM=FB,                       X
               BLKSIZE=0,DDNAME=SYSOUT,LRECL=80
*
* WORKING BUFFERS
BUFFSAVE DS        18F                       REGISTERS SAVE AREA
BUFFR08  DS        F                         REGISTER 08 SAVE
BUFFOUT  DC        CL80' '                   OUTPUT BUFFER
*
         END


Code:
ASMTST5 : PROC OPTIONS (MAIN) REORDER;

 /*******************************************************************/
 /*                                                                 */
 /*  PROGRAM  : ASMTST5                                             */
 /*                                                                 */
 /*  FUNCTION :                                                     */
 /*             TEST ASM CALLS                                      */
 /*******************************************************************/

 DCL ONCODE BUILTIN;

 ON ERROR
    BEGIN;
      PUT SKIP LIST('ONCODE:' || ONCODE);
    END;


 /***************************************************************/
 /*  VARIABLE DECLARATIONS                                      */
 /***************************************************************/
 DCL TEST5 ENTRY OPTIONS(ASM) EXTERNAL;
 DCL 1 PARAM_STRC UNAL,
       2 DDNAME             CHAR(8) INIT('SYSINPL1'),
       2 OPERAT             CHAR(2) INIT('ON'),
       2 RETCOD             BIT(16),
       2 RETMSG             CHAR(80) INIT('');
 DCL PARAM_CHAR             CHAR(92) BASED(ADDR(PARAM_STRC));

 CALL TEST5(PARAM_CHAR);
 PUT SKIP LIST(PARAM_STRC);

 END ASMTST5;


And this is the sysprint message
Code:

IBM0534S ONCODE=8094  Protection exception                                     
         From compile unit ASMTST5 at entry point ASMTST5 at compile unit offset
         00008FD4.                                                             
ONCODE:     8094                                                               


And the Abend Aid report:
Code:

PL/I ONCODE . . . . . . . . : 9                                         
                              SIGNAL ERROR statement executed.         
Abend Code. . . . . . . . . : S0C4-X'4'                                 
Program-Interruption Code . : 0004 (Protection Exception)               
                              An attempt was made to access a protected
                              location using an incorrect storage access
                                                                       
NOTE: Source code information could not be presented because the search
      compiler listing or side-file was unsuccessful for CSECT IBMSSIOE.
                                                                       
Load Module Name. . . . . . : E854539.UTIL.LOADLIB(ASMTST5)             
  At Address. . . . . . . . : 00007800                                 
  Load Module Length. . . . : X'1800'                                   
  Link-Edit Date and Time . : 2010/03/02  12:41:46                     
                                                                       
CSECT Name. . . . . . . . . : IBMSSIOE                                 
  At Address. . . . . . . . : 00008FD0 (Module ASMTST5 offset X'17D0') 
  CSECT Length. . . . . . . : X'14'                                     
  CSECT Language. . . . . . : Assembler (Compiled using High Level Assem
                              R5 M0 on 2007/03/22)                     
                                                                       
Machine Instruction . . . . : 58F0F5AC      L     R15,1452(,R15)       
  At Address. . . . . . . . : 00008FD4 (CSECT IBMSSIOE offset X'4')     
  AMODE . . . . . . . . . . : 24                                       
  Failing Operand . . . . . : Second operand                           
  First Operand (R15) . . . : D6E4E3C9                                 
  Second Operand Address. . : D6E4E975 (Storage invalid)               
  Second Operand Length . . : 4                                         
                                                                       
Instructions around point of failure:                                   
                                                                       
  Offset Hex            Instruction                                     
  ------ -------------- ------------------------------------------------
      -4 58F0 C128      L     R15,296(,R12)                             
   ***** 58F0 F5AC      L     R15,1452(,R15)                           
      +4 07FF           BCR   15,R15                                   



And the JCL:
Code:

//STEP1    EXEC PGM=ASMTST5,REGION=2M PARM='SYSIN   ' 
//SYSINPL1 DD *                                       
RECORD1                                               
RECORD2                                               
//SYSOUT   DD SYSOUT=*                                 
//                                                     
Back to top
View user's profile Send private message
Ranjithkumar

New User


Joined: 10 Sep 2008
Posts: 93
Location: India

PostPosted: Mon Mar 29, 2010 10:17 am
Reply with quote

Try with the below code for house keeping instead of the one you've used in assembler code.
Code:

*                             
* STANDARD ENTRY             
*                             
         STM   14,12,12(13)
         BALR  12,0         
         USING *,12         
         ST    13,SAVEAREA+4
         LA    13,SAVEAREA   
*
* STANDARD EXIT               
*                             
         L     13,SAVEAREA+4
         LM    14,12,12(13)
         XR    15,15       
         BR    14           
*                             

*                                 
* HOUSEKEEPING DSECT REQUIREMENTS 
*                                 
SAVEAREA DS    18F
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: Mon Mar 29, 2010 3:59 pm
Reply with quote

I agree with Ranjithkumar that you're wiping out R12 before you save it. R12 contains the address of the CEECAA from the LE-compliant PL/I caller.

After implementing the standard entry and exit code, substitute R12 with R3 as the sub-program's base-register.

Leave R12 for possible future usage in LE-compliant Assembler.

For sub-program entry linkage, substitute the BALR with LR 3,15 followed by the USING *,3.

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 Return codes-Normal & Abnormal te... JCL & VSAM 7
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
Search our Forums:

Back to Top