Hi, I'm trying to make a static library. I am doing it in RadASM, and MASM32, and I followed this hint to add .lib projects to radasm: http://www.asmcommunity.net/board/index.php?topic=1094&perpage=15&pagenumber=2

I am having some troubles:
1) It only compiles if I declare my procs as C. If I don't declare it, I suppose they're using stdcall, as I put .model stdcall in the beginning. But, it refuses to compile.

2) When I try to link my new .lib to in a program, all the APIs I used in the .lib give error, saying "unresolved external link". But I have put the includes and includelibs in the .lib source.

I hope I've not been too confusing.
Thanks a lot, Kefren
Posted on 2001-10-26 05:56:12 by kefren
kefren,

Its the same old stuff, make sure everything you use has a prototype. In a library you do not need the includelib directive, the libraries are resolved when the library is linked into the app.

.486 ; force 32 bit code
.model flat, stdcall ; memory model & calling convention
option casemap :none ; case sensitive

.code

YourlibraryModule proc parameters etc ....

; code
ret

YourlibraryModule endp

end

Thats the basic syntax for STDCALL libraries.

Regards,

hutch@movsd.com
Posted on 2001-10-26 06:45:41 by hutch--
I solved!!!!

The problem was that I was referring to an include that used C calling conventions, so I had a calling convention error. So, to solve this, I made my lib use the C calling convention, but it prevented all the APIs from working.

I changed the include to stdcall, then I changed the lib, then everything worked!!

Boys, you are geniuses!!

BTW, do I have to preserve any registers?

Thanks a lot!

Kefren
Posted on 2001-10-26 11:28:45 by kefren
in anything called back by windows (ie, wndproc and enumeration
stuff), you will have to preserver ebx,esi,edi if used.
Posted on 2001-10-26 12:12:55 by f0dder
So, only if I expressly use them?
If I do not use ebx, esi or edi in my proc, I don't need to preserve them? Is there any command that uses them (so that I have to preserve them), and does not says clearly it does?
I mean, mov ebx,xxx clearly uses ebx, but is there anything that uses them without saying?

I'm sorry for this dumb questions, and I thank you a lot for you kind answers.

'Bye, Kefren
Posted on 2001-10-27 07:36:01 by kefren
So, only if I expressly use them?
If I do not use ebx, esi or edi in my proc, I don't need to preserve them?


No, because when you don't use them, they are already preserved.. Only preserve ebx, esi or edi when you actually use it.

Is there any command that uses them (so that I have to preserve them), and does not says clearly it does?


I've never seen strange opcodes that play with registers. There are opcodes that don't have a register as an operand, but do use it, like movsb (moves a byte from to and increases both esi and edi), but as you initialized esi and edi yourself when you use this opcode, you probably know you've used them :grin:

Thomas
Posted on 2001-10-27 08:21:07 by Thomas