User's Manual

EXTENDED INSTRUCTION SET
OUTS (Output String to Port) transfers a byte or a word string element to an output port from memory.
Combined with the
REP
prefix, OUTS moves a block of information from a series of consecutive
memory locations indicated by
DS:SI to an output port.
Example:
REP
OUTS
WSTRING.
Assuming
that
the program declares
WSTRING
to be a word-
length string element, the assembler uses the 16-bit form of the
OUTS instruction to create
the object code for the program. The processor repeatedly transfers words from the memory
locations indicated by
DI
to the output port selected by the 16-bit port number
in
DX.
Following each word transfer, the
CPU
decrements CX. The instruction terminates the block transfer
when
CX=O.
After decrementing CX, the processor increments
SI
by
two to point to the next word in
memory
if
DF=O;
it
decrements SI by two if
DF=
1.
4.2
HIGH-LEVEL INSTRUCTIONS
The instructions in this section provide machine-language functions normally found only in high-level
languages. These instructions include
ENTER
and
LEA
VE, which simplify the programming of proce-
dures, and
BOUND, which provides a simple method of testing an index against its predefined range.
ENTER
(Enter Procedure) creates the stack frame required by most block-structured high-level
languages. A
LEAVE instruction
at
the end of a procedure complements an
ENTER
at
the beginning
of
the procedure to simplify stack management and to control access to variables for nested procedures.
Example:
ENTER
2048,3. Allocates 2048 bytes of dynamic storage on the stack and sets up pointers
to two previous stack frames in the stack frame
that
ENTER
creates for this procedure.
The
ENTER
instruction includes two parameters. The first parameter specifies the number of bytes
of dynamic storage to be allocated on the stack for the routine being entered. The second parameter
corresponds to the lexical nesting level
(0-31) of the routine. (Note that the lexical level has
no
relation-
ship to either the protection privilege levels or to the
I/O
privilege level.)
The
specified lexical level
determines
hovv'
many
sets
of stack
frame
pointers
the
CPU
copies
into
the
new stack frame from the preceding frame. This list of stack frame pointers
is
sometimes called the
"display." The first word of the display
is
a pointer to the last stack frame. This pointer enables a
LEA
VE instruction to reverse the action of the previous
ENTER
instruction by effectively discarding
the last stack frame.
After
ENTER
creates the new display for a procedure,
it
allocates the dynamic storage space for
that
procedure by decrementing
SP
by the number of bytes specified in the first parameter. This
new
value
of:SP serves as a base for
aU
PUSH
and
POP
operaiions wiihin
ihai
pro\;!:uun:.
To enable a procedure to address its display,
ENTER
leaves BP pointing to the beginning of the new
stack frame. Data manipUlation instructions that specify
BP
as
a base register implicitly address locations
within the stack segment instead of
tpe data segment. Two forms of the
ENTER
instruction exist:
nested and non-nested.
If
the lexical level
is
0, the non-nested form
is
used. Since the second operand
is
0,
ENTER
pushes BP, copies
SP
to BP and then subtracts the first operand from SP. The nested
form of
ENTER
occurs when the second parameter (lexical level)
is
not
o.
Figure
4-1
gives the formal
definition of
ENTER.
4-2