4-18
PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS
The BOUND instruction explicitly calls the BOUND-range exceeded exception (#BR) handler
if an operand is found to be not within predefined boundaries in memory. This instruction is
provided for checking references to arrays and other data structures. Like the overflow
exception, the BOUND-range exceeded exception can only be raised explicitly with the
BOUND instruction or the INT n instruction with an argument of 5 (the vector number of the
bounds-check exception). The processor does not implicitly perform bounds checks and raise
the BOUND-range exceeded exception.
4.5.PROCEDURE CALLS FOR BLOCK-STRUCTURED
LANGUAGES
The IA supports an alternate method of performing procedure calls with the ENTER (enter
procedure) and LEAVE (leave procedure) instructions. These instructions automatically create
and release, respectively, stack frames for called procedures. The stack frames have predefined
spaces for local variables and the necessary pointers to allow coherent returns from called proce-
dures. They also allow scope rules to be implemented so that procedures can access their own
local variables and some number of other variables located in other stack frames.
The ENTER and LEAVE instructions offer two benefits:
They provide machine-language support for implementing block-structured languages,
such as C and Pascal.
They simplify procedure entry and exit in compiler-generated code.
4.5.1.ENTER Instruction
The ENTER instruction creates a stack frame compatible with the scope rules typically used in
block-structured languages. In block-structured languages, the scope of a procedure is the set of
variables to which it has access. The rules for scope vary among languages. They may be based
on the nesting of procedures, the division of the program into separately compiled files, or some
other modularization scheme.
The ENTER instruction has two operands. The first specifies the number of bytes to be reserved
on the stack for dynamic storage for the procedure being called. Dynamic storage is the memory
allocated for variables created when the procedure is called, also known as automatic variables.
The second parameter is the lexical nesting level (from 0 to 31) of the procedure. The nesting
level is the depth of a procedure in a hierarchy of procedure calls. The lexical level is unrelated
to either the protection privilege level or to the I/O privilege level of the currently running
program or task.
The ENTER instruction in the following example, allocates 2 Kbytes of dynamic storage on the
stack and sets up pointers to two previous stack frames in the stack frame for this procedure.
ENTER 2048,3