CALLS

VAX11

 

CALLS CALL PROCEDURE WITH STACK ARGUMENT LIST

 

Purpose

invoke a procedure with actual arguments or addresses on the

stack

Format

opcode numarg.rl, dst.ab

Operation

{push arg count};

{align stack};

{create stack frame);

{set arithmetic trap enables};

{set new values of AP, EP, PC};

Condition codes

N ß 0;

Z ß 0;

V ß 0;

C ß 0;

Exceptions

reserved operand

Opcodes

FB       CALLS           Call Procedure With Stack Argument List

Description

The numarg operand is pushed on the stack as a longword (byte 0 contains the number of arguments high order 24 bits are used by DIGITAL software). SP is saved in a temporary and then bits 1:0 of SP are replaced by 0 so that the stack is long- word aligned. The procedure entry mask is scanned from bit 11 to bit 0 and the contents of register whose number corresponds to set bits in the mask are pushed on the stack. PC, FP, and AP are pushed on the stack as longwords. The condition codes are cleared. A longword containing the saved two low bits of SP in bits 31:30, a 1 in bit 29, a 0 in bit 28, the low 12 bits of the procedure entry mask in bits 27:16, and the PSW in bits 15:0 with T cleared is pushed on the stack. A longword 0 is pushed on the stack. FP is replaced by SP. AP is set to the saved SP (the value of the stack pointer after the number of arguments operand was pushed on the stack). The trap enables in the PSW are set to a known state. Integer overflow and decimal overflow are affected according to bits 14 and 15 of the entry mask, respectively; floating underflow is cleared. T bit is unaffected. AP is replaced by the saved SP. PC is replaced by the sum of destination operand plus 2 which transfers control to the called procedure at the byte beyond the entry mask.

Notes

1. If bits 13:12 of the entry mask are not 0, a reserved operand fault occurs.

2. On a reserved operand fault, the condition codes are unpredictable.

3. Normal use is to push the arglist onto the stack in reverse order prior to the CALLS. On return, the arglist is removed from the stack automatically.

4. The procedure calling standard and the condition handling facility require the following register saving conventions. R0 and R1 are always available for function return values and are never saved in the entry mask. All registers R2 and R11 which are modified in the called procedure must be preserved in the entry mask.

 

 

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"