AMODE switching
When you have an application that has
COBOL subprograms, some of the COBOL subprograms can be AMODE
31 and some can be AMODE 24. To have this
mixed AMODE support, the calls must be dynamic and
the Language Environment® runtime
options ALL31(OFF) and STACK(,,BELOW) must
be in effect.
If your application consists of only COBOL programs, and you are
using dynamic
calls, each COBOL subprogram will always be entered in the proper AMODE.
For example, if you are using a dynamic call from an AMODE
31 COBOL program to an AMODE 24 COBOL program,
the AMODE is automatically switched.
However, if you are using procedure pointers, function pointers,
or other languages that call COBOL subprograms, you must ensure that
when a COBOL program is called more than once in an enclave, it is
entered in the same AMODE each time that it is called.
The AMODE is not automatically switched in this case.
The following scenario shows that AMODE problems
can arise when procedure pointers are used to call COBOL subprograms.
This scenario is not supported because the COBOL program COBOLY is
not entered in the same AMODE each time that it is
called.
- COBOLX is
AMODE 31. It uses theSETstatement to set a procedure pointer to COBOLZ. COBOLZ is a reentrant program object and isAMODE 31andRMODE 24. COBOLX calls COBOLZ using the procedure pointer. COBOLZ is entered inAMODE 31. - COBOLZ returns to COBOLX.
- COBOLX dynamically calls COBOLY, passing the procedure pointer
for COBOLZ. COBOLY is a reentrant program object,
and is
AMODE 24andRMODE 24. COBOLY is entered inAMODE 24. - COBOLY calls COBOLZ using the procedure pointer. This call causes
COBOLZ to be entered in
AMODE 24, which is not the sameAMODEin which COBOLZ was entered when it was called the first time.
The following scenario uses a mix of COBOL and assembler language.
This scenario is not supported because the COBOL program COBOLB is
not entered in the same AMODE each time that it is
called.
- COBOLA is
AMODE 31. COBOLA dynamically calls COBOLB. COBOLB is a reentrant program object and isAMODE 31andRMODE 24. COBOLB is entered inAMODE 31. - COBOLB returns to COBOLA.
- COBOLA dynamically calls ASSEM10, which is in assembler language.
ASSEM10 is a reentrant program object, and is
AMODE 24andRMODE 24. ASSEM10 is entered inAMODE 24. - ASSEM10 loads COBOLB. ASSEM10 does a
BALRinstruction to COBOLB. COBOLB is entered inAMODE 24, which is not the sameAMODEin which COBOLB was entered when it was called the first time.
Language Environment Programming Reference (ALL31)