enterprise cobol v5/v6 and amode rmode - ibm

16
Enterprise COBOL V5/V6 and AMODE RMODE Tom Ross ‘Captain COBOL’ April 1, 2016

Upload: khangminh22

Post on 23-Apr-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

Enterprise COBOL V5/V6 and AMODE RMODE Tom Ross ‘Captain COBOL’ April 1, 2016

What are AMODE and RMODE?

• Attributes of executables – AMODE 31, RMODE 24

• Program Management Binder options – AMODE=31,RMODE=24

• HLASM Assembler instructions – AMODE 31, RMODE 24

• RMODE is also a COBOL compiler option – RMODE(24|ANY|AUTO) – It was added to support NORENT above the line in the 1990s – NORENT is no longer supported for above the line loading

• NORENT programs have RMODE 24 always in COBOL V5 – There is no such thing as “Compiling with AMODE 31”

2

How does compiler communicate with the BINDER for AMODE and RMODE?

• All COBOL compilers set AMODE and RMODE – BINDER reads this in Object program format – Combines all of the different objects and sets the resulting

attribute in Program Object – All COBOL compilers 1991-2009 set AMODE=31 – COBOL compilers V5 and later set AMODE=MIN

• There is no way to tell the BINDER about RENT – Users still have to set REUS manually if they need it – From the COBOL Migration Guide:

If you compile with the RENT compiler option, you must tell the binder that a module is RENT with REUS=RENT.

3

• For NORENT programs, data is in the executable – RMODE of executable decides above or below the line

• For RENT programs, memory is acquired for WORKING-STORAGE and other areas at run time – DATA(24) says get data below the line – DATA(31) says get it from wherever, which might be above the line,

not guaranteed • The LE runtime options ALL31 and HEAP

• ALL31 – ALL31(OFF) says that some programs are not AMODE 31 – ALL31(ON) says all programs are AMODE 31

• HEAP – HEAP(,,ANYWHERE) says it is OK to get HEAP above the line – HEAP(,,BELOW) says HEAP must be below

4

Where does WORKING-STORAGE data go?

Where does WORKING-STORAGE data go?

• Examples: – RENT program, compiled with DATA(31), run with

HEAP(,,BELOW): • WORKING-STORAGE and other areas below the line

– RENT program, compiled with DATA(24), run with HEAP(,,ANYWHERE)

• WORKING-STORAGE and other areas below the line – RENT program, compiled with DATA(31), run with

HEAP(,,ANYWHERE) • WORKING-STORAGE and other areas acquired from

unrestricted storage (could be above the line)

5

Where does WORKING-STORAGE data go?

• For RENT programs, memory is acquired for WORKING-STORAGE and other areas at run time – Always from HEAP in Pre-V5 compilers – In COBOL V5.1 originally, from WSA, which is a coordinated

effort between C/C++, BINDER and COBOL runtime • Not a good idea! • Too many cases of many large programs bound together

– Load time was VERY slow • Also, STORAGE option no longer worked for initializing

6

Where does WORKING-STORAGE data go?

• COBOL WORKING-STORAGE is allocated from heap storage when the COBOL program is compiled with the RENT option and is in one of the following cases: – Compiled with Enterprise COBOL V4.2 or earlier releases – Compiled with the DATA(24) compiler option – Running in CICS – A COBOL V5.1.1 or later program in a program object that contains only

COBOL programs (except COBOL 5.1.0) and assembler. There are no Language Environment interlanguage calls within the program object and no COBOL V5.1.0 programs.

– A COBOL V5 program in a program object where the main entry point is COBOL V5. In this case, the program object can contain Language Environment interlanguage calls, with COBOL statically linking with C, C++ or PL/I. All COBOL V5 programs within such program objects (even if they are not the main entry point) have their WORKING-STORAGE allocated from heap storage.

– A COBOL V6.1 or later program

7

Where does EXTERNAL data go?

• In addition to affecting how storage is obtained for dynamic data areas (WORKING-STORAGE, FD record areas, and parameter lists), the DATA compiler option can also influence where storage for EXTERNAL data is obtained. Storage required for EXTERNAL data is obtained from unrestricted storage if the following conditions are met: – The program is compiled with the DATA(31) and RENT

compiler options. – The HEAP(,,ANYWHERE) runtime option is in effect. – The ALL31(ON) runtime option is in effect.

8

Example: Mixing new and old (all calls DYNAMIC)

NORENT RMODE (AUTO|24)

Adding New COBOL to Old Apps

NORENT RMODE (ANY)

COBOL V3 P1

P1 DATA

RENT DATA(31)

COBOL V5 P3

P3 DATA

RENT DATA(24)

COBOL V5 P5

P5 DATA

VS COBOL II P2

P2DATA

COBOL V5 P4

P4 DATA

ASM P6 AMODE 24

P6 DATA

16 MB Line

Won't work for P1 DATA or P3 DATA

NORENT RES

Converting assembler to AMODE 31

More than just link-editing with AMODE=31!

Sometimes just changing AMODE 24 to AMODE 31 in source is all you need to do

Before you do that, check out the following first Use of the SPM (set program mask) instruction

LA instruction used to clear the high-order byte of a register

Address fields that are less than 4 bytes

Use of the ICM (insert characters under mask) instruction

AMODE of subprograms

AMODE of CALLing programs

S8216TR / 24FEB02

Converting assembler to AMODE 31

For a good discussion of 31-bit addressability issues, see the z/OS MVS Assembler Services Guide, Chapter 5, "Understanding 31-Bit Addressing.“ Chapter 5.2 has notes on converting from 24- to 31-bit addressing mode.

For 31-bit I/O issues, see DFSMS Macro Instructions for Data Sets Chapter 2, "Non-VSAM Macros" contains information for each macro, regarding 31-bit addressability considerations.

Appendix A in Appendix 1.1 contains a table, indicating for each macro, whether it can be issued in 31-bit amode.

http://www.ibm.com/support/knowledgecenter/SSLTBW_2.2.0/com.ibm.zos.v2r2.ieaa600/planfor.htm?lang=en

S8216TR / 17FEB03

Converting assembler to AMODE 31 Use of the SPM (set program mask) instruction Does the module depend on the instruction length code, condition code, or program mask placed in the high order byte of the return address register by a 24-bit mode BAL or BALR instruction?

One way to determine some of the dependencies is by checking all uses of the SPM (set program mask) instruction. SPM might indicate places where BAL or BALR were used to save the old program mask, which SPM might then have reset. The IPM (insert program mask) instruction can be used to save the condition code and the program mask.

LA instruction used to clear high-order byte of register This practice will not clear the high-order byte in 31-bit addressing mode

Use SR and ICM

S8216TR / 24FEB02

Converting assembler to AMODE 31 Address fields that are less than 4 bytes Are any address fields that are less than 4 bytes still appropriate?

Make sure that a load instruction does not pick up a 4-byte field containing a 3-byte address with extraneous data in the high-order byte

Make sure that bits 1-7 are zero

Use of ICM (insert characters under mask) instruction The use of this instruction is sometimes a problem because it can put data into the high-order byte of a register containing an address, or

It can put a 3-byte address into a register without first zeroing the register.

If the register is then used as a base, index, or branch address register in 31-bit addressing mode, it might not indicate the proper address

S8216TR / 24FEB02

Converting assembler to AMODE 31

S8216TR / 24FEB02

AMODE of subprograms If AMODE 24 then shared data must be below 16M line

AMODE of CALLing programs If AMODE 24, might have to handle mode switching

COBOL dynamic CALL handles this for you

Converting assembler to AMODE 31

S8216TR / 24FEB02

If no issues with previous 6 items:

Use of the SPM (set program mask) instruction

LA instruction used to clear the high-order byte of a register

Address fields that are less than 4 bytes

Use of the ICM (insert characters under mask) instruction

AMODE of subprograms

AMODE of CALLing programs

Just add AMODE statement to the source

Converting assembler to AMODE 31

S8216TR / 24FEB02

ASM2COB CSECT ASM2COB AMODE 31 ASM2COB RMODE ANY * EXTRN COBSUB ============================================ * Save callers regs and chain save areas * ============================================ STM 14,12,12(13) Store incoming registers LR 12,15 Base ASM2COB on Register 12 USING ASM2COB,12 * LA 15,SAVEAREA Get this program's save area ST 13,4(,15) Save caller's save area pointer ST 15,8(,13) Store back this program's save * save area pointer LR 13,15 Load standard save area Register 13 LOAD EP=IGZEDT4,ERRET=NOTFOUND LR 1,0 MVC PGMHDR,6(1) Move in program header WTO MF=(E,WTOMSG) Display program header DELETE EP=IGZEDT4 B SETPLIST * NOTFOUND WTO 'IGZEDT4 was not found',ROUTCDE=(11) *