Use assembly to write static libraries

zhaozj2021-02-16  78

In fact, as long as you write a normal assembly language document, then use ML / C / COFF / CP XXX.ASM to compile the OBJ file, then use lib.exe to pack the lib file. The original shape of the function that needs to be called when the call is called, and it needs attention to its call mode. If it is stdcall when defined, STDCALL needs to be used when calling (if the header file should be unified), if you use it for C / C , define the stdcall, assembly: ... stdcall ... Hello Proc in C / C is: void __stdcall _hello ();

Because the Hello will become __hello @ 0 after compiling the compiler, the front is two underscores, while only one underline _hello @ 0 is named when C / C is named, so it is necessary to declare in C / C . Add "_" manually in front of the function.

In addition, the code compiled by different compilers may not be compatible, such as the LIB compiled using the ML and LIB in VC.NET 2003 cannot be called in VC6.0, but the specific cause may still be different because of the way. I have encountered that when using ML compile LIB, some functions are commanded to _xx, and some is __xx, how to order, specific rules I am not very clear :(. But in VC The way is consistent, _xx @ x - I refer to __stdcall.

转载请注明原文地址:https://www.9cbs.com/read-11499.html

New Post(0)