I am a HLASM developer. However I have need to use Enterprise COBOL.
I want to pass to arguments and I know I need to use the linkage section. That is the easy part.
One of the elements in one of the pass structures is a ADDRESS Pointer, and I want to use it since it points to an area in CSA. How can I address that area in COBOL?
The last time I wrote COBOL I used BLL Cells and the New Enterprise COBOL has some new features I don't know how to use.
PROCEDURE DIVISION USING a-nice-name-for-the-pointer.
SET ADDRESS OF your-structure TO a-nice-name-for-the-pointer
Then you can use your-structure and its subordinate fields for whatever you want.
Bear in mind that simply defining it as linkage between the two program may do what you want. If you use the pointer in the ASM and then pass the address, you can just put that on the PROCEDURE DIVISION USING ... and define the structure in the LINKAGE SECTION and you are good-to-go. Your choice.
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
Steve,
Like Assembler, COBOL builds a parmlist of addresses, which points to R1.
When the called sub-program is invoked, it obtains addressability to the parmlist by pointing to R1 (pretty standard stuff). When the sub-program is COBOL, all of this is done under the covers.
COBOL (like Assembler) will set the top high-order bit of the left-most byte of the last parmlist address to B'1000' (X'8'), so you can verify that you've received all of your arguments.
COBOL does employ a means to OMIT a parm (keyword is OMITTED), but I always set up a dummy one-byte field (WS-OMIT, initialize to X'00') as this has always worked for me in the past. I've used this when the called sub-program is invoked in a CICS environment (DFHEIBLK, DFHCOMMAREA, third-parm) as opposed to Batch (one-parm).
If you're passing a POINTER to the sub-program, when the COBOL sub-program obtains addressability, you've then received the ADDRESS of a POINTER-ADDRESS (this should make sense).
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
Bill,
If storage has not been allocated in the Caller's LINKAGE for the POINTER, I'm not too sure this will work and may raise a S0C4 Protection Exception.
Ideally, the structure POINTER can be defined to WS, set to the address of the structure and passed as an argument to the sub-program or the structure itself can be specified in the CALL USING, as once the sub-program is invoked, the structure's address can be addressed directly, as it will exist as one of the parmlist addresses off of R1.
Maybe I've misunderstood?
Off topic: For those with long commutes, because of the Ice-Storm, it took me nine hours to get home last night (actually arrived at 1:30am Atlanta time this morning).
Luckily, I had an empty 24oz coffee cup in the car (Posthumous thanks Keith Kalland, wink wink, nod nod).
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Bill,
I was reading it as ASM calling the COBOL program. The pointer passed from the ASM, named on the PROCEDURE DIVISION USING ... and then the "structure" given addressability by using SET ADDRESS OF ... TO pointer-from-the-USING.
With the alternative of doing the pointer-value-to-actual-location in the ASM and just getting it to the COBOL program as a normal parameter.
With no storage defined for the pointer, or it not passed to the COBOL program, yes, it will flat-out fail with a S0C4, when lucky, or trash something up with random areas of storage, when unlucky...
I did assume that the pointer exists in the ASM program. If it doesn't either the whole thing is moot or I completlely missed something :-)