RET Instruction

Purpose:To transfer control from a procedure back to the calling program
Format:opcode
Operation: {restores SP From FP};
{restores registers};
{drop stack alignment};
{restore PSW};
{If CALLS then remove arglist};
Condition
Codes:
N <- restored PSW<N>
Z <- restored PSW<Z>
V <- restored PSW<V>
C <- restored PSW<C>
Exceptions:Reserved Operand
Opcodes:
04RETReturn from Procedure
Description: SP is replaced by FP plus 4. A longword containing the 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 the saved PSW in bits 15:0 is popped from the stack and saved as a temporary. PC, FP and AP are replaced by longwords 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 of the temporary is 1 (Indicating that this procedure was called with a 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.
Notes:
1.
A reserved operand fault occurs if tmpl<15:8> NEQ 0.The value of tmpl<28> is ignored.
2.
On a reserved operand fault, the condition codes are unpredictable.
3.
The procedure calling standard and condition handling facility assume that procedures which return a function value or status code do so in R0 or R) and R1.