AMODE and RMODE
AMODE and RMODE
AMODE and RMODE
If your application includes Assembler programs, or you are mixing OS/VS dialect
programs with other COBOL dialects, you may be affected by the AMODE setting,
which affects addressing mode.
On the mainframe, storage can be allocated either above or below "the line". "The line"
means the point at which memory addresses require four bytes of storage to hold
them rather than three bytes - that is, addresses above 16Mb. The mainframe is
limited to 31-bit addressing, but pointer variables are always 32 bits long and the unused
bits are available for use by user programs. The format of these pointer variables on the
mainframe is different to that native to the Intel PC platform, and to cope with this
Workbench used a variety of different techniques (CONVERTPTR, REDEFPTR and
recently MFPM AMODE).
Older mainframe compilers such as OS/VS COBOL were created before MVS supported
addresses above the line and so only support 24-bit addressing. Newer compilers such
as VS COBOL II support both 31-bit and (for interoperability) 24-bit addressing. This
support is provided by the mainframe compiler directive DATA(24|31) and linker
directives AMODE(24|31|ANY) and RMODE(24|ANY).
When a program is compiled with the DATA(24) directive, the data items declared in its
Data Division are allocated in storage below the line. This enables those data items to be
passed as CALL parameters to 24-bit programs such as OS/VS programs - if these
parameters were not allocated below the line you would most likely receive an S0C4
abend.
Mainframe Express more fully emulates the addressing modes of the mainframe than
did Workbench. It does this through the use of Mainframe Pointer Manager (MFPM).
This maintains a mainframe virtual address space to map mainframe-style "above and
below the line" addresses to real 32-bit PC memory addresses. Pointer variables in your
programs are MFPM addresses stored in mainframe format and so you can redefine and
manipulate them just as you would on the mainframe.
The amount of storage allocated to your progam at execution time is configurable using
the Max. memory below 16Mb and the Max. memory above 16Mb fields on the
Execution tab of the Project Settings dialog box. This replaces the MF/370 option
VM370.
For further information see the chapter Run-time Considerations in your Assembler
Option Technical Guide .
Run-time Considerations
This chapter provides information about various aspects of the run-time behavior of
Assembler programs.
The memory requirements of an Assembler program are indicated by its AMODE (or
addressing mode) and RMODE (or residency mode). AMODE governs the type of
addresses the program uses, while RMODE indicates where the program must be located
when it is loaded for execution.
You can set AMODE to 24 or 31 in Mainframe Express, since it emulates both types of
addressing by mapping mainframe-style above and below the line addresses to real 32-bit
PC memory addresses. An AMODE (24) program can only access memory below the
line, while an AMODE(31) program can access memory both below and above the line.
• RMODE(24) indicates that the program must be loaded into memory below the
line
• RMODE(31) indicates that the program can be loaded either below or above the
line.
When the Assembler Option run-time system is initialized, it allocates an area of memory
called the system queue area to the executable program. You can specify how much of
this memory is below the line and how much is above the line. The main executable
program and any other executables that it loads are loaded into memory below or above
the line depending on the program's RMODE settings. When a program issues requests
for extra memory using the macros GETMAIN or STORAGE OBTAIN, it can specify
whether the memory needs to come from the below-the-line allocation or the above-the-
line allocation, depending on its addressing needs.
Getting access to the type of memory you require involves several steps. You must:
1. Specify how much memory the program needs below the line and above the line,
using the Max. memory below 16Mb line and Max. memory above 16Mb line
fields. You can find these fields on the Assembler page of the Execution page of
the Project Settings dialog box.
2. Specify the addressing mode of the program and of any programs that the main
program calls, using the Addressing mode field. Addressing mode appears in
two places:
o On the Link page of the Assembler page in the Build Settings for Project
dialog box or the Build Settings for filename dialog box. Set addressing
mode here for each Assembler program that does not need a separate link
file to control the production of an executable code file.
o On the General page of the Linker page in the Build Settings for Project
dialog box or the Build Settings for filename dialog box. Set addressing
mode here for each Assembler program that does need a separate link file
to control the production of an executable code file.
3. Ensure that all your GETMAIN or STORAGE OBTAIN macro calls indicate
which type of memory is required.
If your program only needs to address memory below the line, you should:
1. Set Max. memory below 16Mb line to the maximum amount of memory below
the line that your program requires. The default is 3Mb and the maximum is
16Mb.
2. Set Addressing mode to AMODE(24) for the main program and for each
program that the main program loads.
3. Omit the LOC parameter from all GETMAIN or STORAGE OBTAIN macros
issued by your program.
If your program needs to address memory above the line, you should:
1. Set Max. memory above 16Mb line to the maximum amount of memory above
the line that your program requires. The default is 3Mb and the maximum is 2Gb.
2. Set Addressing mode to AMODE(31) for the main program and for each
program that the main program loads.
3. Set LOC=ANY in all GETMAIN and STORAGE OBTAIN macros issued by
your program.
If your program needs to address both types of memory, that is, you have a mix of some
modules that use memory below the line and others that use memory above the line, you
should:
1. Set Max. memory below 16Mb line to the maximum amount of memory below
the line that your program requires. The default is 3Mb and the maximum is
16Mb.
2. Set Max. memory above 16Mb line to the maximum amount of memory above
the line that your program requires. The default is 3Mb and the maximum is 2Gb.
3. Set Addressing mode to AMODE (24) for each program to be loaded that uses
memory below the line.
4. Set Addressing mode to AMODE (31) for each program to be loaded that uses
memory above the line.
5. To allocate memory below the line, omit the LOC parameter from all GETMAIN
and STORAGE OBTAIN macros that the module issues.
6. To allocate memory above the line, set LOC=ANY in all GETMAIN and
STORAGE OBTAIN macros that the module issues.
7. Use the Assembler instructions BASSM or BSM to transfer control between
programs that use different addressing modes.
Notes:
• If a program that uses 31-bit addressing needs to manipulate 24-bit addresses, you
must include code to clear the unused byte of the address before any instruction
that sets a register to a new address. These instructions include LA, BAL, BALR,
EDMK and TRT.
• You can only set LOC=ANY on the RU and RC formats of the GETMAIN macro.
The R format of GETMAIN is restricted to memory below the line.
You specify the residency mode of a program and of any programs that the main program
calls using the Residency mode field. Residency mode appears in two places:
• On the Link page of the Assembler page in the Build Settings for Project dialog
box or the Build Settings for filename dialog box. Set residency mode here for
each Assembler program that does not need a separate link file to control the
production of an executable code file.
• On the Advanced page of the Linker page in the Build Settings for Project dialog
box or the Build Settings for filename dialog box. Set residency mode here for
each Assembler program that does need a separate link file to control the
production of an executable code file
Note:
If you set AMODE to 31 and RMODE to 31, but the Assembler module contains 24-bit
addresses, the Linker overrides your RMODE setting and loads the module below the
line, and displays a warning message.
You can use subpools to help manage your memory requirements in just the same way as
you do on the mainframe. A subpool is a logical grouping of memory allocations that can
be de-allocated with a single FREEMAIN or STORAGE RELEASE macro statement.
Subpools are available for memory both above and below the line.
The online help contains full specifications of all the macros and SVCs supported; click
Help Topics on the Mainframe Express Help menu, then on the Contents tab click
Reference, Assembler Option, Macro Instructions or Supervisor Services.
• Assembler services macros. These provide services for interfacing with the
Assembler Option run-time system, managing memory, calling other programs
and for general functions such as saving and restoring registers. There are also
services for accessing the catalog and for dynamically allocating and deallocating
data sets at execution time.
• File handling macros. These provide access to files. There is more information
about these macros in the chapter File Handling.
Many Assembler services macros equate to SVCs. You can choose whether to code the
macro or its equivalent SVC, but in general it is easier to use the macros. The following
table relates the SVCs and service macros:
http://coding.derkeiler.com/Archive/Cobol/comp.lang.cobol/2003-11/0015.html
http://publibz.boulder.ibm.com/cgi-
bin/bookmgr_OS390/BOOKS/igymg202/APPENDIX1.10