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:
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
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.
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.
Joined: 28 May 2009 Posts: 20 Location: Oklahoma City, OK USA
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).
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
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.
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
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
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.
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)
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
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.