COBOL Manual for TNS and TNS/R Programs
Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs—522555-006
23-20
TNS Addressing Modes
TNS Addressing Modes
TNS HP COBOL programs use standard (16-bit) addressing for all items in the File
Section, all items in the Working-Storage Section, and items in the Linkage Section for
which standard access mode is specified. HP COBOL programs use extended (32-bit)
addressing for all items in the Extended-Storage Section and all items in the Linkage
Section for which the standard access mode is not specified. Programs written in
languages other than COBOL use both 16-bit and 32-bit addressing, with certain data
structures always using 32-bit addressing.
When a formal reference parameter (in the called routine) is 16-bit-addressed, the
corresponding actual parameter (in the calling routine) can be any HP COBOL data
item except a special register or an item declared in the Linkage Section or Extended-
Storage Section.
When a formal reference parameter (in the called routine) is 32-bit-addressed, the
corresponding actual parameter (in the calling routine) can be any HP COBOL data
item except a special register.
When an HP COBOL program passes a 32-bit-addressed parameter to a routine that
expects a 16-bit-addressed parameter, the COBOL85 compiler performs the necessary
conversion. The passed data item must begin in the leftmost byte of a word. If the data
item begins (or can begin) in a byte other than the leftmost byte, the compiler delivers
a warning, and it is your responsibility to verify that the addressing is correct.
In a called routine, the code that handles actual parameters from the calling routine is
generated according to the addressing mode that the called routine specifies for the
formal parameters. This code can include both instructions that use 16-bit addressing
and instructions that use 32-bit addressing. Instructions that use 16-bit addressing
execute faster, but cannot address items in extended memory.
Native Addressing Modes
Native programs use 32-bit addressing for all data items. Many HP COBOL data items
are byte-addressed. Some data items in other languages are 2-byte addressed. When
you pass a byte-addressed item to a routine that expects a 2-byte-addressed
parameter, the data item must be aligned on a 2-byte boundary; otherwise, problems
can arise, because the called routine is expecting an aligned parameter.
Special registers are not addressable data items. If passed as parameters, they must
be passed by value.