This question is for Hutch, or anyone else with experience making modular libs...

I was tinkering with statements like this:


.code
main1:
...
...
end main1

main2:
...
...
end main2


Till now, to get a truely modular lib, as i understood it, you needed separate asm "modules" in separate files, and have them all compressed into one lib. This allows me to ensure only the modules i want get linked, and not the entire lib.

My question is this: With the above layout, will it still work? Can i link only "Main2" module (if i pack this one asm file into a lib), and not "Main1?". I can test it myself, but I figure it would be just simpler to ask :)

Thanx again.
:alright:
NaN
Posted on 2002-05-28 14:56:23 by NaN
masm ignores everything after the 'end' directive, so no you cant :).
Assuming it didn't stop assembly when it reaches a end directive,
you'd get both "main1" and "main2" code in your output executable,
as they both reside in the same obj. Microsoft *has* invented a
method of "function linkage" usable with coff, but I doubt masm
supports it.
Posted on 2002-05-28 15:28:30 by f0dder
Thanx f0dder, it does assemble cleanly tho. Maybe i will try an put errors in the "main2" to test the assembler. Probably not tho, got alot on my "coding" plate as is... ;)

NaN
Posted on 2002-05-28 22:14:01 by NaN
Microsoft *has* invented a method of
"function linkage" usable with coff, but I doubt
masm supports it.


I don't know if the new MASM 7.0 supports it, but
MASM 6.15 and below does not.
It seems to me that "function linkage" is done
by creating multiple sections in a coff object,
with each section containing exactly one function.
So, an object file created from VC is in effect a
library in a special file format. Actually, I
think that is a neat trick, postponing segment
consolidation until the link time.

I had done a similar thing as NaN did with
segment directives, because VC generated .asm
files always do that. But, (as you expect)
it was not possible because all segments with
the same name are combined at the assemble time.
I did not understand what VC was doing until I
dumped the object file and read the output.
Anyway that was quite stupid of me to forget
what MASM does with the segment.
Posted on 2002-05-29 04:05:36 by Starless
NaN,

The best way to make a block of code is to still put it in a proc with a prototype like normal and make a single object module with it. I have found if its simple code that you do not end up with the stack overhead like normal and there is a pair of options that prevent a stack frame from being created if you wish to avoid that overhead as well.

OPTION PROLOGUE:NONE

It still makes sense to put every non dependent piece of code in its own proc as you avoid the problem of granularity where you add code that is not used.

I have done some testing in the past and where you include an object module (usually in a library) it is added at the end of the code section after the local functions in the code. It is generally a very efficient method of adding extra code that you need and it has all the convenience of libraries as well.

Regards,

hutch@movsd.com
Posted on 2002-05-30 03:20:43 by hutch--