User`s guide

How the MACRO Compiler Functions on Different Platforms
2.5 Declaring JSB Routine Entry Points
2.5 Declaring JSB Routine Entry Points
In assembled VAX MACRO code and compiled OpenVMS Alpha and OpenVMS
I64 object code alike, JSB routine parameters are typically passed in registers.
A JSB routine that writes to registers sometimes saves and restores the contents
of those registers, unless the new contents are intended to be returned to a caller
as output. However, because it is fairly common for a VAX MACRO module to
save and restore register contents by issuing instructions such as PUSHL and
POPL, saving only the low 32 bits of the register contents, the compiler must add
64-bit register saves/restores at routine’s entry and exit points.
The compiler can compute the set of used registers, but without complete
knowledge of the routine’s callers (which may be in other modules), it cannot
determine which registers are intended to contain output values. For this
reason, the user must add, at each JSB routine entry point, a .JSB_ENTRY or a
.JSB32_ENTRY directive that declares the routine’s register usage.
2.5.1 Differences Between .JSB_ENTRY and .JSB32_ENTRY
The compiler provides two different ways of declaring a JSB entry point. The
.JSB_ENTRY directive is the standard declaration, and the .JSB32_ENTRY
directive is provided for cases when you know that the upper 32 bits of the 64-bit
register values are never required to be preserved by the routine’s callers.
In routines declared with the .JSB_ENTRY directive, the compiler, by default,
saves at routine entry and restores at routine exit the full 64-bit contents of
any register (except R0 and R1) that is modified by the routine. If a register is
not explicitly modified by the routine, the compiler will not preserve it across the
routine call. You can override the compilers default behavior by means of register
arguments that can be specified with the .JSB_ENTRY directive, as described in
Section 2.6.
When .JSB32_ENTRY is used, the compiler does not automatically save or restore
any registers, thus leaving the current 32-bit operation untouched. The compiler
will only save and restore the full 64-bit value of registers you explicitly specified
in the preserve argument.
If the routine you are porting is in an environment where you know that no caller
ever needs to have the upper 32 bits of a register preserved, it is recommended
that you use the .JSB32_ENTRY directive. It can be much faster for porting code
because you do not have to examine the register usage of each routine. You can
specify the .JSB32_ENTRY directive with no arguments, and the existing 32-bit
register push/pop code will be sufficient to save any necessary register values.
Note
The OpenVMS Alpha or OpenVMS I64 compilers for other languages may
use 64-bit values. Therefore, any routine which is called from another
language or which is called from another MACRO routine that is in
turn called from another language cannot use .JSB32_ENTRY.
How the MACRO Compiler Functions on Different Platforms 2–11