在编程或阅读源码时,经常会碰到invoke与call这两个方法名或者名词,按照现在的中文翻译来看,都是“调用”的
意思,但两者到底是什么关系呢,秉着好奇的观点,查询了一些资料,仍然没有弄太明白,就把搜集到的一些观点放
在这里,供参考参考:
1. 来自于ms的术语搜索:
参考链接 http://www.microsoft.com/Language/en-US/Search.aspx
call:调用
To transfer program execution to some section of code (usually a subroutine) while saving the necessary information to allow execution to resume at the calling point when the called section has completed execution. When a subroutine call occurs, one or more values (known as arguments or parameters) are often passed to the subroutine, which can then use and sometimes modify these values.
大致中文意思:
当保存了必要的信息来允许执行恢复到call点当call段完成执行时,将程序执行转换到一些代码片段(通常是子程序)。当子程序call发生时,通常会传递一到多个值(作为实参或形参)到子程序,子程序随后可以使用这些值,有些时候还会对这些值做一些修改。
invoke:调用
To call or activate; used in reference to commands and subroutines.
大致中文意思:
call或者激活,在到命令和子程序的引用中使用。
2. 论坛回帖
Call是编程者主动调用某个method,是一种有意的活动,invoke可能是有意的,也可能是非有意的,可能作为某一Action的unintended result. 所以invoke有时候又译成激活。
3. 汇编语言中:
INVOKE是编译器支持的伪指令,会检查参数. CALL会直接去栈里取参. INVOKE最后也会变成 PUSH PUSH ... CALL 的形式.
TASM5.0:
extrn ExitProcess:proc
call ExitProcess,0
:0040103C 6A00 push 00000000
:0040103E E8B5020000 call KERNEL32.ExitProcess
MASM32:
invoke ExitProcess,NULL
:00401026 6A00 push 00000000
:00401028 E801000000 call KERNEL32.ExitProcess
本质一样,在MASM32下还是用invoke保险。但是TASM下缺失参数一样会出错的。
参考链接:http://bbs.bccn.net/thread-238091-1-1.html