You are on page 1of 8

AMODE

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.

6.1 COBOL Programs


For COBOL programs, this is enabled by the settings AMODE(24|31) and DATA(24|31).
The OS/VS COBOL dialect uses AMODE(24) DATA(24) and this is not configurable
(just like the mainframe compiler). Other COBOL dialects default to AMODE(31)
DATA(31) but these can be altered. With Workbench the AMODE directive was available
but was not enabled by default and there was no DATA directive. The AMODE and
DATA settings in Mainframe Express make the CONVERTPTR and REDEFPTR
directives obsolete.
You set AMODE and DATA in the Addressing mode and Data mode fields, which are
on the Dialect dialog box accessed by clicking on the General tab of the COBOL tab
in the Build Settings dialog box.

6.2 Assembler Programs


For Assembler programs addressing mode is controlled by the AMODE setting. There is
also an RMODE setting that controls whether the program itself must reside in memory
above or below the line. For autolinked load modules you set AMODE and RMODE on
the Link page of the Assembler page in the Build Settings for Project dialog box. For
programs that require a link file, you set AMODE using the Addressing mode field on
the General page of the Linker page, and RMODE using the Residency mode field on
the Advanced page of the Linker page. The AMODE setting decides the addressing
mode in which the first Assembler module in an executable program is called. By default
it is set to AMODE 31. If your Assembler program expects to be started in 24-bit mode,
ensure you set AMODE to AMODE 24. This replaces the MF/370 option AMODE370

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 .

6.3 CICS Shared Storage


CICS shared storage may be restricted to below the line or may extend above the line
depending on the setting of the Region addressing mode dropdown list on the CICS tab
of the Project Settings dialog box. If your region contains 24-bit programs that need to
access this storage, ensure the setting of Region addressing mode is AMODE 24, which
is the default. If all the programs that access the storage are 31-bit, you can safely change
this setting to AMODE 31. This replaces the configuration option in the SIT for CICS
Option for Workbench.

Run-time Considerations
This chapter provides information about various aspects of the run-time behavior of
Assembler programs.

2.1 Memory Requirements


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.

There are two AMODE values:

• AMODE(24) indicates 24-bit (three-byte) addressing - memory below the line


• 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.

There are two RMODE values:

• 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.

2.1.1 Reserving Memory for Execution

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.

2.1.2 How to Specify Your Memory Requirements

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.

The following sections cover most possibilities.

2.1.2.1 Program Only Uses Memory Below the Line

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.

2.1.2.2 Program Only Uses Memory Above the Line

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.

2.1.2.3 Program Uses Memory Below and Above the Line

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.

2.1.3 Setting Residency Mode

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

The valid combinations of AMODE and RMODE are:

• AMODE(24) and RMODE(24)


• AMODE(31) and RMODE(31)
• 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.

2.1.4 Using Subpools

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.

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.

2.2 Macros and SVCs


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.

There are two categories of macro:

• 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:

SVC Macro Description


4 GETMAIN L LC LU E Get memory (list, element and variable requests).
EC EU, VC, VU
5 FREEMAIN L LC LU Free memory (list, element and variable requests).
E EC EU, VC, VU
6 LINK Link to another Assembler program.
8 LOAD Load another Assembler program or a COBOL program.
9 DELETE Delete a loaded module.
10 GETMAIN R Get memory (R type register requests).
11 TIME Get the time of day and the date.
13 ABEND Terminate the program and open the Assembler debugger
if possible, or display information about the state of the
program when the abend occurred.
14 SPIE Handle a program exception within the executing
module.
26 CATALOG and Uncatalog a data set; return a volume list for a data set.
LOCATE
29 SCRATCH Delete a data set.
35 WTO Display a message on the screen.
WTOR Display a message on the screen and wait for a reply.
39 LINKC2 Link to a COBOL program.
41 IDENTIFY Associate a name you specify with an already loaded
program.
62 Remove the executing program. There is no
corresponding macro.
99 DYNALLOC Allocate or deallocate a resource at execution time.
103 XLATE Convert between ANSI and EBCDIC.
120 GETMAIN RU, RC, Get memory (RU and RC type register requests)
VRC, VRU;
FREEMAIN R, RU, Free memory (all types of register requests).
RC, VRC and VRU;
STORAGE Get memory or free memory
CALL Transfer control to a statically linked module. There is no
corresponding SVC.
CAMLST Create parameter list for CATALOG, LOCATE or
SCRATCH. There is no corresponding SVC.
DEQ Relinquish control of one or more serially reusable
resources. There is no corresponding SVC.
ENQ Request control of one or more serially reusable
resources. There is no corresponding SVC.
EXTRACT Obtain information from control block. There is no
corresponding SVC.
RETURN Restore registers and sets the address to return to. There
is no corresponding SVC.
SAVE Save registers. There is no corresponding SVC.
SPLEVEL Test or set the level of MVS macro compatibility. There
is no corresponding SVC.
WAIT Wait for event completion. There is no corresponding
SVC.

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

You might also like