Amode and Rmode
Amode and Rmode
This chapter provides information about various aspects of the run-time behaviour of Assembler
programs.
On the mainframe, an area of memory can be located either below the line or above the line. The
term 'the line' means the point at which the address of an area of memory requires four bytes to
hold it. Three-byte addresses can point to memory up to 16Mb. Any area of memory starting at a
higher point than this requires a four-byte address. Four-byte addresses are actually 31-bit
addresses, since bit 0 is used for other purposes. A 31-bit address can point to memory up to 2Gb.
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.
AMODE(31) indicates 31-bit addressing - memory above and below the line.
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
AMODE(31) and RMODE(24): use this combination where the Assembler program contains
24-bit address constants but needs to be executed in 31-bit addressing mode so that it can
handle 31-bit addresses passed as parameters by calling COBOL programs.
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 create a subpool simply by including the SP parameter in a GETMAIN or STORAGE OBTAIN
macro statement. Valid subpool numbers are 0 through to 127, 131 and 132. If you omit the SP
parameter from your GETMAIN and STORAGE OBTAIN macro statements, all memory is allocated in
subpool 0, unless you specify the NONCAN Linker directive, in which case all memory is allocated in
subpool 132.
Assembler Option supports a number of macros and SVCs (supervisor calls). Those that are
supported are compatible with the equivalent macros and SVCs on the mainframe, so you shouldn't
need to alter your code just for the PC environment. However, some macro-options may not be
supported. This means that they will compile, but will not have any effect when executed. There are
also some macros which are supported in stub form, that is, macro code exists but it simply returns
control to the calling program. These stubs are provided for macros that perform tasks that have no
meaning on the PC. An example stub macro is provided in \mfe\mfasm\include\stub.mac; you can
use this to create your own stub macros.
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:
26 CATALOG and LOCATE Uncatalog a data set; return a volume list for a data set.
120 GETMAIN RU, RC, VRC, Get memory (RU and RC type register requests)
VRU;
FREEMAIN R, RU, RC, VRC Free memory (all types of register requests).
and VRU;
STORAGE Get memory or free memory
RETURN Restore registers and sets the address to return to. There is no
corresponding SVC.