User`s guide
Recommended and Required Source Changes
3.1 Stack Usage
Recommended Change
To correct the first problem and detect the second, use the coding technique
illustrated in this example. Consider the following code example:
; Build a descriptor on the stack.
;
MOVW length, -(SP)
MOVB type, -(SP)
MOVB class, -(SP)
MOVAL buffer, -(SP)
Replace this code with the following:
SUBL2 DSC$S_DSCDEF, SP ; pre-allocate space on stack
MOVW length, DSC$W_LENGTH(SP)
MOVB type, DSC$B_DTYPE(SP)
MOVB size, DSC$B_CLASS(SP)
MOVAL buffer, DSC$A_POINTER(SP)
3.1.5 Quadword Moves Into the VAX SP and PC
Due to architectural differences between VAX and Alpha/Itanium computers, it is
not possible to completely emulate quadword moves into the VAX stack pointer
(SP) and the program counter (PC) without programmer intervention. The VAX
architecture defines R14 as the SP and R15 as the PC. A MOVQ instruction with
SP as the target would simultaneously load the VAX SP and PC, as shown in the
following example:
MOVQ R0,SP ; Contents of R0 to SP, R1 to PC
MOVQ REGDATA, SP ; REGDATA to SP
; REGDATA+4 to PC
If the compiler encounters a MOVQ instruction with SP as the destination, it
generates a sign-extended longword load from the supplied source into the stack
pointer and issues the following informational message:
%AMAC-I-CODGENINF, (1) Longword update of Alpha SP, PC untouched
Recommended Change
If the intended use of the MOVQ instruction was to achieve the VAX behavior, a
MOVL instruction should be used, followed by a branch to the intended address,
as shown next:
MOVL REGDATA, SP ; Load the SP
MOVL REGDATA+4, R0 ; Get the new PC
JMP (R0) ; And Branch
If the intended use of the MOVQ instruction was to load the stack pointer with
an 8-byte value, the EVAX_LDQ built-in should be used instead, as shown next:
EVAX_LDQ SP, REGDATA
3.2 Instruction Stream
The VAX MACRO coding practices and VAX instructions described in this section
either do not work on OpenVMS Alpha or on OpenVMS I64 or they can produce
unexpected results.
Recommended and Required Source Changes 3–3