汇编语言多文件程序设计

来源:互联网 发布:海尔32电视网络售价 编辑:程序博客网 时间:2024/06/05 11:11

汇编语言多文件程序设计

2011-11-7 晴 于韶关仁化

变量的共享

         关键字externdef跟C语言中的extern相似。在定义与引用模块(源文件)中的声明的一致的。

声明格式:

         EXTERNDEF [[langtype]] name:type [[, [[langtype]] name:type]]...

MSDN Remars:

         If name is defined in the module, it is treated as PUBLIC. If name is referenced in the module, it is treated as EXTERN. If name is not referenced, it is ignored. The type can be ABS, which imports name as a constant. Normally used in include files.

 

函数的共享

         函数在调用之前必须使用proto语句提前声明。否则MASM会提示" error A2190:INVOKE requires prototype for procedure"。要在本模块中使用其它模块中的文件时,只需在调用模块作个proto声明就行了。

 

程序示例:

;-------------------main.asm--------------------------.386.model stdcall, flatoption casemap:nonefnprotoexterndef string:byte.datastringdb'hello world!', 0.codestart:invoke fnretendstart;-------------------fn.asm--------------------------.386.model stdcall, flatoption casemap:noneinclude msvcrt.incincludelib msvcrt.libexterndef string:byte.codefnprocinvoke crt_printf, offset stringretfnendpend#------------------makefile------------main.exe:main.obj fn.objlink /subsystem:console /nologo main.obj fn.obj.asm.obj:ml /c /coff /nologo {1}lt;clean:del *.obj

 ====================================================

dll模块中的数据调用:

include               保证编译时通过

includelib 保证链接时通过

dll文件               保证运行时正常

 

 

 

 

 

 

 

 

 

原创粉丝点击