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

S0C4 Abend when running a converted code


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Thu Jun 25, 2009 5:09 pm
Reply with quote

I have converted a cobol -I code to cobol 390 this cobol -1 code was calling a assembler routine. The assembler routine is used to open files which would be used in JCL.

This assembler program was running fine with Cobol -1 code but when I am using the same assembler code for Cobol 390 it was abending with S0C4 abend.


I have replaced the following code in the assembler program

Before:
Code:
OPEN  MASTIN 


After :
Code:
STORAGE OBTAIN,LENGTH=DCBSIZE2,LOC=ANY,ADDR=VS24ADDR2   
L     R12,VS24ADDR2                                     
MVC   0(DCBSIZE2,R12),MASTIN                           
OPEN  ((R12)),MODE=31     


VS24ADDR2 DS F
DCBSIZE2 EQU *-MASTIN


Before:
Code:
CLOSE MASTIN


After
Code:
L     R12,VS24ADDR2                         
CLOSE ((R12)),MODE=31                       
STORAGE RELEASE,ADDR=(R12),LENGTH=DCBSIZE2 


This assembler code was 24 bit so I have added the following code:

Code:
PROG1  MZENTUR 2,MATWORK,APWORK,TRASREC,IOCDE       
         EXTRN PROG2   


Code:
PROG1  MZENTUR 2,MATWORK,APWORK,TRASREC,IOCDE       
         EXTRN PROG2                                   
PROG1 AMODE 31                                         
PROG1 RMODE ANY 



I could able to see that S0C4 abend is happening in the below line.

Code:
GET   MASTIN,ASSYWORK


The display which I have kept is not comming after the above line

Please find the declartions below

Code:
ASSYWORK DS    4096C 
MASTIN   DCB   DDNAME=IDR101SV,           
               MACRF=GM,                 
               DSORG=PS,                 
               DCBE=MASTINX               
DCBSIZE2 EQU   *-MASTIN                   
MASTINX  DCBE  EODAD=MASTEOF,RMODE31=BUFF .


Please let me know how to resolve this.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 25, 2009 8:03 pm
Reply with quote

I have forgotten everything I knew about assembler, but as a BROT,

I always have assembler modules that are CALLed by COBOL modules
LINKed above the line - amode any, rmode 31 (or the other way around).

To CALL a below the line assembler module from COBOL (which is usually above the line - unless your site is all below the line)
you need a wrapper or something. It is just easier to insure that the assembler module execute above the line.
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: Sat Jun 27, 2009 4:57 am
Reply with quote

Substitute R12 with another register. R12 (when called from a HLL running under LE), contains the address of the CAA (Common Anchor Area).

Also, if you want to retain AMODE 24 in Assembler, specify DATA(24) in the COBOL compile options.

Regards,
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Mon Jun 29, 2009 12:15 pm
Reply with quote

Thanq Bill. I tried the approch whic you mention but it is abending in some other place.Please find the details below.

This assembler modules is loading an address of a program using the below code

Code:
APROG2 DC    A(PROG2)


Code:

 LA    R1,TABLEARG   
 SLR   15,15         
 L     R15,APROG2 
 BALR  R14,R15       


The abend aid is showing the below details

Code:
       000002B2  410035CE      LA    R0,1486(,R3)         
       000002B6  1FFF          SLR   R15,R15             
       000002B8  BFF71031      ICM   R15,X'7',49(R1)     
       000002BC  05EF          BALR  R14,R15             
NSI==> 000002BE  D20335C63086  MVC   1478(4,R3),134(R3)   
       000002C4  968035CA      OI    1482(R3),X'80'       
       000002C8  92C545CE      MVI   1486(R4),X'C5'       
       000002CC  41D0357A      LA    R13,1402(,R3)       
       000002D0  411035C2      LA    R1,1474(,R3)       


It is abending at this code
Code:
BALR R14,R15


these are the values in register ar error
Registers at time of error

Code:
REG HEX       Decimal         
R0  000084FC          34,044 
R1  10F95FA0     284,778,400 
R2  10F8E040     284,745,792 
R3  80007F2E  -2,147,451,090 
R4  00008F2E          36,654 
R5  00007BE6          31,718 
R6  00000000               0 
R7  10F8E070     284,745,840 
R8  10F8E010     284,745,744 
R9  10F8E018     284,745,752 
R10 90F8E068  -1,862,737,816 
R11 10F95FA0     284,778,400 
R12 00029B58         170,840 
R13 00007F6C          32,620 
R14 800081E6  -2,147,450,394 
R15 00005000          20,480 
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon Jun 29, 2009 3:50 pm
Reply with quote

@ rakeshnaredlla !

So you have converted a cobol-I code to cobol-390 code. Ok Sir. But
why have you modified the called Ass-Programm, which is called???

What happens, if you use the original Ass-Programm. Remember Bill's hint about DATA(24) in Cob-Programm.

I could not realy comprehend, why you changed that simple OPEN command, in conjunction with a GETMAIN.

Here's a little example, using OPEN/CLOSE in an Ass-Pgm below the line using Dataareas above the line.

IF and EIF are in-house macros, same as IF-THEN-ELSE-ENDIF in Cobol.
So same as CLC and BRUNCH, please ignore.

USING IHADCB,R11


CHGAMODE 31,R14
L R11,=A(S3OLD)
IF DCBOFLGS,Z,DCBOFOPN,TM
OPEN ((R11),INPUT)
LH R7,DCBLRECL
EIF
CHGAMODE 24,R14


CHGAMODE 31,R14
L R11,=A(S3OLD)
IF DCBOFLGS,NZ,DCBOFOPN,TM
CLOSE ((R11))
EIF
CHGAMODE 24,R14

DROP R11


* Definitions

S3OLD DCB DDNAME=S3OLD,
MACRF=(GL),DSORG=PS,
EODAD=OLDVSNEW_CLOS,
DCBE=S3OLD_DCBE

S3OLD_DCBE DCBE RMODE31=BUFF
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Mon Jun 29, 2009 6:12 pm
Reply with quote

Hi Umeysan,

The reason for changing the Assembler code is.

The loads which is getting created after converting the cobol code to cobol 390 is reflecting 24/24 because of this assembler programs which are in 24/24 .So to make the load as 31/ANY we include the RMODE(ANY) AMODE(31) in the cobol link member but due to this the assembler was showing S0C4 abend, to resolve this we did the changes in assembler program.

CHGAMODE is not available under our assembler environment.

Please let me know if you have any questions.

Thank you,
Rakesh
Back to top
View user's profile Send private message
CaptBill

New User


Joined: 28 May 2009
Posts: 20
Location: Oklahoma City, OK USA

PostPosted: Mon Jun 29, 2009 6:41 pm
Reply with quote

A rule I learned about 24/31 but programs:

A 24 bit program can call a 31 bit program with no problem.
A 31 bit program can call a 24 bit program, but will usually have problems.
If the called program is 24 bit, then compile the calling program with AMODE(24).
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: Tue Jun 30, 2009 4:45 am
Reply with quote

Are you passing 24-Bit storage from the COBOL caller to the Assembler sub-program as a separate parm?

Could you post your R1 parmlist that you're mapping-to in the sub-program?

Also post your COBOL CALL USING statement.

I'm not trying to discourage you using Assembler, but have you checked-out the EXTERNAL attribute in COBOL (introduced in VS/COBOL II, 20+ years ago), which includes (amongst others) FILES being defined as EXTERNAL to the COBOL CALLER?

If you rewrote the sub-program in COBOL, it might make things easier going forward as well as increase the maintenance ability for Tech's who don't know Assembler.

Also, LE (Language Environment) has some handy-dandy Callable Service routines, such as CEECRHP (Create Heap), where you can specify the option as to where the Heap Storage needs to be allocated (IE: Below The Line), coupled with CEEGTST (Get Heap Storage --- Similar to a GETMAIN and/or STORAGE OBTAIN), using the options which you defined in the previous CEECRHP call.

Just some thoughts....

Regards,
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Tue Jun 30, 2009 4:44 pm
Reply with quote

Hi Bill,

No I am not passing 24-Bit storage from the COBOL caller to the Assembler sub-program as a separate parm.
But in my cobol link i am using this MODE AMODE(31),RMODE(ANY).

Below is the call details
Code:
CALLPROG EQU   *             
         LA    R13,REGSTORE   
         LA    R1,TABLEARG   
         L     R15,PROG2   
         BALR  R14,R15       
         B     RETURN   



declaration are
Code:
REGSTORE DS    18F
TABLEARG DS    0F 



Please find the Cobol Call using statements

This cobol program is getting called from assembler code:

PROCEDURE DIVISION USING RECORD-1
WKAREA
CODE.

From my assembler program the code to this cobol is like this

Code:
        EXTRN PROG2

APROG2 DC    A(PROG2) 
         LTORG             
         DS    0H           
         DS    0H           
         DS    0H           
         DS    0H           
         DS    0H 

LA    R13,REGSTORE   
LA    R1,TABLEARG   
L     R15,ABDREXIM   
BALR  R14,R15 



Please let me know if you need any thing else.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 30, 2009 5:02 pm
Reply with quote

Okay, you originally said
Quote:
I have converted a cobol -I code to cobol 390 this cobol -1 code was calling a assembler routine.
and now you say
Quote:
This cobol program is getting called from assembler code:
I think problem number one is you don't understand what you're doing -- or at least you are not communicating fully and completely what you are doing since you've contradicted yourself here.

Please start from the beginning and repost. If you are calling a COBOL program from Assembler, post the Assembler instructions that set up the parameters you're passing in register 1 through the BALR R14,R15. Post the Assembler variable definitions for the variables you're passing through register 1, too. Also post the LINKAGE SECTION of the COBOL program so we can see how the COBOL program is seeing the same variables.

If you are calling Assembler from COBOL, post the COBOL call statement, the variable definitions used in the CALL, and the associated Assembler variables referencing the calling program fields.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jun 30, 2009 5:08 pm
Reply with quote

and the amode rmode attributes of both as revealed in the loadlib.

from the member display list of the loadlib and PF11 - cut and paste the rmode amode attributes.

please.
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Tue Jun 30, 2009 6:32 pm
Reply with quote

Robert,

This is what happening with my Assembler, it is getting called from a Cobol program and it also calls another cobol Program.

Here is the example Prg1 calls----> ASMPROG Calls----> Prg2.

Please find the call statement which is getting used for calling an assembler.

Code:
CALL 'ASMPROG' USING RECORD-1 
                               MAST                     
                                TRANSL                     
                                IO-CODE.               

Assembler code details


Code:
BDRRTIO9 MZENTUR 2,MASTWORK,APLWORK,TRANSREC,IOCODE
                 EXTRN PRG2   
BDRRTIO9 AMODE 31                                     
BDRRTIO9 RMODE ANY     
                L     R6,SAVE6
                B     PROCEED


CALLPRG2 EQU   *           
         LA    R13,REGSTORE
         LA    R1,TABLEARG 
         L     R15,APRG2
         BALR  R14,R15     
         B     RETURN       

 
REGSTORE DS    18F         
TABLEARG DS    0F           
AASSYNK  DC    A(ASSYWORK) 
MASORGEN DS    F           
AEXIMCDE DC    A(EXIMCODE) 
ASSYWORK DS    4096C       
EXIMCODE DS    C           
APRG2     DC    A(PRG2)   



Code change in the Cobol program(PRG2) which is getting called from assembler is

Code:
LINKAGE SECTION.                                       
01 REC-1                           PIC X(200).         
01 WKAREA.                               
    05 NEW-TAG                  PIC X(603).           
01 CODE                           PIC X.                   
PROCEDURE DIVISION USING REC-1
                         WKAREA
                         CODE.


Job is abending at this place in assembler program
Code:
CALLPRG2 EQU   *           
         LA    R13,REGSTORE
         LA    R1,TABLEARG 
         L     R15,APRG2
         BALR  R14,R15      ------ at this point
         B     RETURN                 



Also please let me know the changes which I have made for opening the and closing the files is correct or not.Please let me know is there anyother way that I can code Opening, Closing ,Put & Get statements.

Code:
MODE AMODE(31),RMODE(ANY)---this line of code is newly added so as to make the load reflect 31/any
INCLUDE PRODOBJ(PRG1)------ this the cobol main module from which the assembler is getting called.
INCLUDE PRODOBJ(ASMPROG)------ this is  my assembler program
INCLUDE PRODOBJ(PRG2)------)------ this the cobol module  which is   getting called from assembler.
ENTRY PRG1 
NAME PRG1 (R)


Register 1 was used as below

MVC ARGUMENT(16),0(R1)

ARGUMENT DS 0F

Thank you,
Rakesh
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 30, 2009 6:53 pm
Reply with quote

Okay, your PRG2 COBOL program is expecting a 200-byte area, followed by a 603-byte area, followed by a 1-byte area. However, the assembler program is passing an address to a 4096-byte area (which is wasteful but not wrong), a full word (which may or may not be an address), and an address to a 1-byte area. If MASORGEN in the assembler code is not set to an address before the call to PRG2, that could easily explain your abend since COBOL would assume the full word points to the address of a 603-byte memory area.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts purge jobs with return code 0 and ret... JCL & VSAM 4
No new posts ABEND 0717 during starting IMS IMS DB/DC 0
No new posts Call an hlasm from REXX in batch and ... CLIST & REXX 4
No new posts What is the most complex abend you've... Mainframe Interview Questions 8
No new posts Running REXX through JOB CLIST & REXX 13
Search our Forums:

Back to Top