call

8086 and later

Call Procedure

call imm16 {near} | call imm32 {near} | call imm64 {near} | call r/m16 {near} | call r/m32 {near} | call r/m64 {near} | call imm16 {far} | call imm32 {far} | call imm16:imm16 | call imm32:imm32 | call imm16:imm16 {far} | call imm32:imm32 {far} | call imm16:imm32 | call imm16:imm32 {far} | call mem16 {far} | call mem32 {far} | call mem64 {far}

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 \c{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.

The CALL r/m forms given above are near calls; NASM will accept the NEAR keyword (e.g. CALL NEAR [address]), even though it is not strictly necessary.

Loading...

Forms

Every form of call the assembler accepts, from NASM's own instruction table. The second column is the processor that introduced the form; a badge marks a form that needs an extension, that is lockable, or that long mode dropped.

FormSinceNotes
call imm16 {near}8086nolong
call imm32 {near}386nolong
call imm64 {near}386long
call r/m16 {near}8086nolong
call r/m32 {near}386nolong
call r/m64 {near}x86-64long
call imm16 {far}8086nolong
call imm32 {far}386nolong
call imm16:imm168086nolong
call imm32:imm32386nolong
call imm16:imm16 {far}8086nolong
call imm32:imm32 {far}386nolong
call imm16:imm32386nolong
call imm16:imm32 {far}386nolong
call mem16 {far}8086nolong
call mem32 {far}386
call mem64 {far}386long