Intel 210200-002 Baby Furniture User Manual


 
CALL
CALL
PROCEDURE
CALL
Operation:
if
Inter-Segment
then
(SP)
--
(SP) - 2
((SP)
+ 1 :(SP))
--
(CS)
(CS)
--
SEG
(SP)
--
(SP) - 2
((SP) + 1 :(SP))
--
(IP)
(IP)
--
DEST
Description:
CALL procedure-name
CALL activates
an
out-of-line procedure, sav-
ing information
on
the stack to permit a RET
(return) instruction in the procedure to
transfer control back to the instruction follow-
ing the CALL. The assembler generates a dif-
ferent type
of
CALL
instruction depending
on
whether the programmer has defined the pro-
cedure name as
NEAR
or FAR. For control to
return properly, the type
of
CALL instruction
must match the type
of
RET instruction
that
exits from the procedure. (The potential for a
mismatch exists if the procedure and the
CALL are contained in separately assembled
programs.) Different forms of the CALL
instruction allow the address
of
the target pro-
cedure to be obtained from the instruction
itself (direct CALL) or from a memory loca-
tion or register referenced by the instruction
(indirect
CALL), In the following descrip-
tions, bear in mind that the processor auto-
matically adjusts
IP to point to the next
instruction to be
executed before saving it
on
the stack.
For an intrasegment direct CALL,
SP (the
stack pointer)
is
decremented by two and IP
is
pushed onto the stack.
The
target procedure's
relative displacement (up to ±32k) from
the CALL instruction
is
then added to the
instruction pointer. This
CALL
instruction
2-59
Flags Affected:
None
form
is
"self-relative" and appropriate for
position-independent (dynamically relocat-
able) routines in which the
CALL
and
its
target are moved together in the same segment.
An intrasegment indirect CALL may be made
through memory
or
a register.
SP
is
decre-
mented by two;
IP
is
pushed
onto
the stack.
The target procedure offset
is
obtained from
the memory word or 16-bit general register
referenced in the instruction
and
replaces
IP.
For
an
inter segment direct CALL,
SP
is
decre-
mented by two,
and
CS
is
pushed
onto
the
stack. CS
is
replaced by the segment word con-
tained in the instruction.
SP again
is
decremented by two.
IP
is
pushed
onto
the
stack
and
replaced by the offset word in the
instruction.
For
an
inter segment indirect
CALL
(which
only may be made through memory),
SP
is
decremented by two, and
CS
is
pushed onto
the stack. CS
is
then replaced by the content
of
the second word of the doubleword memory
pointer referenced by the instruction.
SP
again
is
decremented by two, and
IP
is
pushed onto
the stack
and
replaced by the content
of
the
first word
of
the doubleword pointer refer-
enced by the instruction.