User`s guide

How the MACRO Compiler Functions on Different Platforms
2.3 Routine Calls and Declarations
Consider the following VAX call:
PUSHL R2
PUSHL #1
CALLS #2,XYZ
This VAX call is compiled as follows on OpenVMS Alpha:
SEXTL R2, R17 ; R2 is the second parameter
LDA R16, 1(R31) ; #1 is the first parameter
LDA R25, 2(R31) ; 2 parameters
LDQ R26, 32(R13) ; Get routine address
LDQ R27, 40(R13) ; Get routine linkage pointer
JSR R26, R26 ; Call the routine
This VAX call is essentially compiled as follows on OpenVMS I64:
sxt4 r46 = r28 ; Load 2nd output register
adds r45 = 1, r0 ; Load 1st output register
adds r25 = 2, r0 ; 2 parameters
adds r12 = -16, r12 ; Extra octaword per calling standard
br.call.sptk.many br0 = XYZ ;; ; Call the routine
adds r12 = 16, R16 ; Pop extra octaword
mov r1 = r32 ; Restore saved GP
The exact code generated might be different in order to adjust for differences
between the OpenVMS Alpha calling standard and the OpenVMS I64 calling
standard.
For a CALLS instruction with a variable argument count or a CALLG instruction,
the compiler must call an emulation routine which unpacks the argument list
into the OpenVMS Alpha or OpenVMS I64 format. This has two side effects.
On OpenVMS VAX systems, if part of the argument list pointed to by a CALLG
instruction is inaccessible, but the called routine does not access that portion of
the argument list, the routine will complete successfully without incurring an
access violation. On OpenVMS Alpha or OpenVMS I64 systems, since the entire
argument list is processed before calling the routine, the CALLG will always
incur an access violation if any portion of the argument list is inaccessible. Also,
if either the argument count of a CALLG instruction or a CALLS instruction with
a variable argument count exceeds 255, the emulated call returns with an error
status without ever invoking the target routine.
2.4 Declaring CALL Entry Points
Because of the differences between the OpenVMS VAX, OpenVMS Alpha, and
OpenVMS I64 calling standards (see Section 2.3), the compiler must translate all
VAX parameter references to AP in the following ways:
It converts parameter references off AP in the called routine into direct
register and stack references to the new OpenVMS Alpha or OpenVMS I64
parameter locations.
It detects references to AP that may result in aliased references to the
parameter list, or that use variable offsets which cannot be resolved at
compile time. The compiler mimics VAX argument lists by packing the
quadword register and stack arguments into a longword argument list on the
stack. Two arguments to the .CALL_ENTRY directive have been created for
this purpose (see Section 2.4.1).
In the latter case, the practice is known as homing the argument list. The
resulting homed argument list is in a fixed position in the stack frame, so all
references are FP-based.
2–8 How the MACRO Compiler Functions on Different Platforms