RET

VAX11

 

RET     RETURN FROM PROCEDURE

 

Purpose

transfer control from a procedure back to calling program

Format

opcode

Operation

{restore SP from FP};

{restore registers};

{drop stack alignment};

{restore PSW};

{If CALLS, remove arglist};

Condition codes

N ß restored PSW <3>;

Z ß restored PSW <2>;

V ß restored PSW <1>;

C ß restored PSW <0>;

Exceptions

reserved operand

Opcodes

SP is replaced by FP plus 4. A longword containing stack alignment bits in bits 31:30, a CALLS/CALLG flag in bit 29, the low 12 bits of the procedure entry mask in bits 27:16, and a saved in a temporary PC, FP, and AP are replaced by long- words popped from the stack. A register restore mask is formed from bits 27:16 of the temporary. Scanning from bit 0 to bit 11 of the restore mask, the contents of registers whose number is indicated by set bits in the mask are replaced by longwords popped from the stack. SP is replaced by the sum of SP and bits 31:30 of the temporary. PSW is replaced by bits 15:0 of the temporary. If bit 29 in the temporary is 1 (indicating that the procedure was called by CALLS), a longword containing the number of arguments is popped from the stack. Four times the unsigned value of the low byte of this longword is added to SP and SP is replaced by the result.

Description

1. A reserved operand fault occurs if temporary1 <15:8> NEG 0.

2. On a reserved operand fault, the condition codes are Unpredictable. The value of temporary1 <28> is ignored.

3. The procedure calling standard and condition handling facility assume that procedures which return a function value or a status code do so in R0 or R0 and R1.

 

 

Example 1

 

The following program demonstrate 3 functions calls.

 

.text

main: .word 0

      calls $0, func1

      calls $0, func1

      calls $0, func1

 

      pushl $0

      calls $1, .exit  

 

func1:      .word 0

 

      movl $99, r1

      pushl r1

      pushal format

      calls $2, .printf

      ret

.data

format: .asciz "R1 is %d\n"