1. When a call instruction executed, the following two-step operation:
A). The current ip and ip cs or pushed onto the stack.
B). jumps to the label.
After the call lable (reference), the push current ip, execution proceeds to the label.
call far ptr lable, to achieve inter-segment transfers. Cs and push the current ip, transferred to a far ptr lable performed at reference numeral.
call reg16 / mem16 (16 bit registers / 2 bytes of memory), the current after ip push proceeds to reg16 / mem16.
Call word ptr, the current ip will push, transferred to a memory cell at word ptr performed.
2. analog C function call template language
. 1 Data segment 2 g_szString DB " the HelloWorld $ " . 3 Data ends . 4 . 5 Stack1 segment Stack . 6 ORG 64 . 7 Stack1 ends . 8 . 9 of code1 segment 10 the ASSUME CS: of code1, DS: Data . 11 fun_add:; __ the cdecl 12 is Push BP; BP push 13 mov bp, sp; saved stack bottom 14 15 Sub SP, for 20 h; lifting the stack, application of local variable space 16 MOV Word PTR [bp- 04h], 03h; local variables . 17 MOV Word PTR [bp- 02h], 02h 18 is . 19 MOV AX, [BP + . 6 ]; Parameter B 20 is MOV BX, [BP + . 8 ]; Parameter A 21 is the Add AX, BX; calculating 22 is 23 is MOV SP, BP 24 POP BP 25 26 is RETF; __ the cdecl Called 27 of code1 ends 28 29 code segment 30 the ASSUME CS: code, DS: Data 31 is the START: 32 MOV AX, . 5 33 is Push AX; parameter = A . 5 push 34 is MOV BX, . 6 35 Push BX; parameter = B . 6 Yazhan 36 37 [ call far ptr fun_add 38 add sp,4 ;平衡栈 39 40 mov ax,4c00h 41 int 21h 42 ret 43 44 code ends 45 end START
After following a call fun_add FIG display instruction, no instruction is executed inside fun_add reference, where the return address onto the stack and the parameters
The figure shows the implementation of the call, the current call stack before displaying call numbers and designations instructions drawn, so relatively clear