Re: Static Libraries and Assembly Language
- From: "DougDarrow" <douglas-darrow@xxxxxxxxxxx>
- Date: 19 Aug 2006 07:23:57 -0700
My experience with asm is from about 14 yrs ago, and was not extensive
even then. worse yet, I haven't even been involved with computers, let
alone programming in ANY language in that time. So I'm going to enter
this thread, as a nearly complete rookie, as a way to clear up my own
thinking on such matters as static and dymanic libs so, all of you more
knowledgable and experienced readers ( and that includes both you Betov
and you Randy) please feel free to jump in and correct me if I'm
totally off the wall in what I have say.
And since Betov is the first to extensively deliniate his stance on the
issue, I'll start there:
Betov wrote:
Well, ... If so, my points, now... :)I don't that that at any time, whether historically or currently, the
Historically, Static Libs had two concerns:
1) Compilations Times.
In the old days, the usage of pre-compiled things
were significantly reducing the time. This point is,
nowadays, completely dead, given the speeds of the
actual Processors and Assemblers.
PURPOSE of libs was to reduce compilation time. The material contained
within a lib STILL has to be compiled at some time whether at .exe
compile time or at .lib creation time. Doesn't matter. That code still
had to be compiled. (or assembled, if you prefer.) The only way that
compilation time was of CONCERN was secondarily, i.e. of course you'd
want that code to be as efficient and as optimized as possible. If at
some point you decided to chang that particularly .lib, and you hadn't
yet compiled the final .exe, you could just plug in the changed .lib,
whithout changing the main source file, which would tend to reduce
final assembly or compilation time. But that was not it's main purpose
then or now.
Another, purpose (historically and well as currently) was program
modularity. It's certainly easier to write a small, single purpose
routine and provide a well defined interface to that routine than it is
to code one huge, monolithic application. And, after all, isn'tthat
just what asm is all about? Arn't you just just calling even smaller,
well defined routines using asm language opcodes? And if you're chasing
down a bug it would certainly be easier to do if you could remove
already proven chunks of code from your search area. Any code that's
put into a .lib has (hopefully) already been thoroughly debugged so you
don't need to waste time searching for this nefarious critter there.
2) Code Re-use.I agree that this is probably the MAIN purpose of (static).libs
This is _the_ actual point.
Good for not having to reinvent the wheel, of course.
So, what we are talking about, here, is not about knowing
if the old Static Libs practice is interresting or not,
but to see what _Code Reuse_ Methods are good, and "good
for what", and "depending on what".
Basically, calling for a Lib (Static or Dynamic) is Black-Incompatible? How is that inclmpatible? Aren't you hooking into the
Box Programming. Of interrest when calling for the OS Functions,
there usage, in Assembly should decrease with the importance
of the called materials. Take, as an example, what Master Pdf
did, in the Satic Library he designed for his HLL, in the "Math"
or in the "Chars" Folders... You will see there, innoumerous
functions, usually one page or two long, that, in Assembly,
would take one or two instructions. That is, an extreeme
case of absurd Black-Box programming, doing nothing but
hidding Assembly entirely. In such cases, there is a choice
to be done in between the HLL, and the Assembler road. Here,
clearly, the usage of the Static Library, is utterly incompatible
with any form of Assembly.
'black box' of the OS or hardware of the machine itself? Does not asm
language itself supply mothods for doing this? So why then does making
use of other methods supplied by asm (such as calling a .lib function)
become, suddenly INcompatible?
At the other end of the picture, i have been given the exampleNo, its not. Every Zip API I've ever seen comes with a dll. at least on
of the "zip" Static Library, that seems to be provided without
Sources and without (not sure, at all) a DLL choice (is this
true?).
DOS or WinDOS. after all, DLLs themselves are a MS defined/implemented
format. But that's not to say I've seen/know about about ALL
distributions of ZIP. As I said, I'm prety new to this stuff.
If true, in such a case, the usage of Static Lib wouldNo, It's not your fault.
be accurate... as long as there would be no other choice...
and as long as nobody is going to rewrite all of that stuff.
Whose responsability, if the DLL version does really not exist?
Well... not mine, for sure... :))
Now, back to the real problem of Code Re-use... Depending onWell, if you created the code in the first place then you have the
the size of the Routines, they can be given in a Librarian
Tool (like the one of RosAsm), for the small Snippets. This
method has evident and huge advantages:
1) You can customize the selected Routine to your exact needs.
access to the source and and you can message it and use however you
want. If someone else created the code, then you have no right to use
and/or change that code unless the give you that right...in which case
they probably gave you that source code as well. So you can use the
original source code in your app if you so desire. So what's the
problem.
2) You have it inside your Source. So, no Black-Box, here.How is that simpler that just calling the routine you want? And how
3) In case of error, the Source Level Debugger can point it
out, in the Source.
4) The Method is faster (just a mouse selection, and a [Ctrl]
[V]), simpler, and more secure than the other ones.
"more secure"? You mean more secure from code piracy? When anyone
could look at your source file and see just how that routine is
implemented? Or do you mean more secure from your (mouse selection and
a [Ctrl] [V]) missing the last character on the last lin_? Or the
complete last line? Or the fuction that your code calls which never got
pulled in at all?
Still considering the sizes and the types of usage, there alsoI personally think there is a BIG difference between them. You've got
are the cases of "Modules". For this also, there are better
methods than Static Linking, with most of the same advantages
as above ("Include" thingies...).
Then, there are the DLLs. I suspect that some guys could wrongly
believe that the DLLs calls would 'consume' something... like
"calling time", or something like this, which is perfectly wrong.
There is no real difference in between calling a Function in a
DLL or inside the Binary. Just indirect, instead of direct... :
Nothing.
control of whether you use a static lib function or not. If you don't
want to use it then don't. If you want to change it then change it. But
a DLL? You must use it if you're programming for Windows. And you
can't change it because you don't have the source for it and you
wouldn't dare change it if you DID have the source for it because any
change to it would affect so much else that also uses it. (like the
OS)
I don't understand how this will "bloat the Binaries". The compiled (or
Considering all of these solutions, why on earth would one want
to pratice Black-Box Programming, in Assembly, while still
bloating the Binaries? What for?
assembled, if you prefer) code gets pulled into the final assembled
..exe whether as preassembled external module or as redundantly
duplicated source code lines. But, if you don't want make use of the
functionality of static libs that is certainly you're right. You don't
have to.
Sorry for the long winded reply. Once again, if I'm mistaken anywhere
in this post please correct me. I'm willing to listen to any reasonable
contrary opinion or corrections hopefully learn something in the
bargain.
-Doug
.
- Follow-Ups:
- Re: Static Libraries and Assembly Language
- From: Evenbit
- Re: Static Libraries and Assembly Language
- From: Betov
- Re: Static Libraries and Assembly Language
- References:
- Static Libraries and Assembly Language
- From: rhyde
- Re: Static Libraries and Assembly Language
- From: Betov
- Re: Static Libraries and Assembly Language
- From: rhyde
- Re: Static Libraries and Assembly Language
- From: Betov
- Re: Static Libraries and Assembly Language
- From: Eman
- Re: Static Libraries and Assembly Language
- From: Betov
- Static Libraries and Assembly Language
- Prev by Date: Re: MASM on the Web
- Next by Date: Re: Static Libraries and Assembly Language
- Previous by thread: Re: Static Libraries and Assembly Language
- Next by thread: Re: Static Libraries and Assembly Language
- Index(es):
Relevant Pages
|
Loading