A.5.18 CALL: Call Subroutine
CALL imm ; E8 rw/rd [8086]
CALL imm:imm16 ; o16 9A iw iw [8086]
CALL imm:imm32 ; o32 9A id iw [386]
CALL FAR mem16 ; o16 FF /3 [8086]
CALL FAR mem32 ; o32 FF /3 [386]
CALL r/m16 ; o16 FF /2 [8086]
CALL r/m32 ; o32 FF /2 [386]
CALL calls a subroutine, by means of pushing the current instruction
pointer (IP) and optionally CS as well on the stack, and then jumping to
a given address.
CS is pushed as well as IP if and only if the call is a far call, i.e.
a destination segment address is specified in the instruction. The
forms involving two colon-separated arguments are far calls; so are the
CALL FAR mem forms.
The immediate near call takes one of two forms (CALL imm16/imm32),
determined by the current segment size limit. For 16-bit operands,
you would use CALL 0x1234, and for 32-bit operands you would use
CALL 0x12345678. The value passed as an operand is a relative offset.
You can choose between the two immediate far call forms (CALL imm:imm)
by the use of the WORD and DWORD keywords: CALL WORD 0x1234:0x5678) or
CALL DWORD 0x1234:0x56789abc.
The CALL FAR mem forms execute a far call by loading the destination
address out of memory. The address loaded consists of 16 or 32 bits
of offset (depending on the operand size), and 16 bits of segment.
The operand size may be overridden using CALL WORD FAR mem or
CALL DWORD FAR mem.
The CALL r/m forms execute a near call (within the same segment),
loading the destination address out of memory or out of a register. The
keyword NEAR may be specified, for clarity, in these forms, but is not
necessary. Again, operand size can be overridden using CALL WORD mem or
CALL DWORD mem.
As a convenience, NASM does not require you to call a far procedure
symbol by coding the cumbersome CALL SEG routine:routine, but instead
allows the easier synonym CALL FAR routine.