The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ran on March 13, 2007, 09:43:33 PM

Title: I need crtdll.inc or replacement
Post by: Ran on March 13, 2007, 09:43:33 PM
Hello,

I did find a masm32 project where crtdll.inc and crtdll.lib is needed.
I did search the Web but cannot find it.
I did find crtdll.lib!
So I think there must be a replacement(s) for this older? crtdll.inc.
But which one(s)?

Greetings,

Ran



Title: Re: I need crtdll.inc or replacement
Post by: Vortex on March 13, 2007, 09:56:05 PM
Hi Ran,

The attached zip file contains crtdll.lib and crtdll.inc

[attachment deleted by admin]
Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 14, 2007, 07:33:43 AM
Hi Vortex,

It's is good to hear from You again.
I am not often on the board but everytime I am You get me out of trouble.

Thanks a lot,

Ran
Title: Re: I need crtdll.inc or replacement
Post by: Vortex on March 14, 2007, 06:06:17 PM
Hello Ran,

You are welcome. I am glad if I could be helpful.
Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 16, 2007, 11:40:25 AM
Hello Vortex,

I have some info about the crtdll.inc and crt.lib You sent me.

When assembling I got the following errors:

- atol error A2111 conflicting parameter definition
               A2112 Proc and prototype calling conventions conflict
- isalpha     idem
- islower    idem
- isupper   idem
- div error syntax error PROTO
-fabs idem

But since I do not use this functions I deleted them from crtdll.inc

Linking the crtdll.lib gave me following problem:

fatal error LNK1115: / MACHINE option required

But on http://search.cpan.org/src/SREZIC/Tk-804.027_500/PNG/zlib/contrib/vstudio/readme.txt
I did find the link: http://www.winimage.com/zLibDll/crtdll.zip
where I could download another crtdll.lib and this one is much bigger = 499 Kb
Anyway this new crtdll.lib did disappear my LNK1115 error.
Now my program runs happely!  :U

This is just informative because I tought You have to know this problems with crtdll.

Best of greetings and thanks again,

Ran
Title: Re: I need crtdll.inc or replacement
Post by: MichaelW on March 16, 2007, 12:14:39 PM
If I try to combine crtdll.inc with masm32.inc and macros.asm, there are conflicts on lines:
320
337
339
341
342
345
354
359
360
364
368
378
383
387
454
Which are easy enough to get around, but even modifying the LINK command line I could not get around the:

LINK : fatal error LNK1115: /MACHINE option required

Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 16, 2007, 03:13:09 PM
Michael,

Did You try to replace Your crtdll.lib in masm32 with the one from:

http://www.winimage.com/zLibDll/crtdll.zip

This way I got rid of the "LINK : fatal error LNK1115: /MACHINE option required" error.

And try the crtdll.inc from Vortex above, it gives a lot less errors. (errors line 320-337-341-378-383-387)

Greetings,

Ran

Title: Re: I need crtdll.inc or replacement
Post by: Vortex on March 16, 2007, 05:51:46 PM
Hi Ran,

I am sorry for the trouble. To create the import library, I used Pelle's librarian Polib. For the include file, I used the lib2inc tool. I will analyze the import library you found.
Title: Re: I need crtdll.inc or replacement
Post by: MichaelW on March 16, 2007, 09:12:17 PM
Ran,

There is no crtdll.lib in the MASM32 package. The library that you linked appears to be a static library, judging from the size and the presence of object module names. I did not attempt to use it because I have no need and because it is from an unknown (to me) source. Is there some reason why you cannot just use the MASM32 msvcrt.lib and include file?
Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 16, 2007, 09:23:56 PM
Michael

Then I got a lot of unsupported symbols like
free
malloc
strlen
strcpy
strcat
_kbhit
_getch
_getche

Ran
Title: Re: I need crtdll.inc or replacement
Post by: MichaelW on March 16, 2007, 10:17:54 PM
For the MASM32 msvcrt.lib all of the function names have a "crt_" prefix. So the correct names are:

crt_free
crt_malloc
crt_strlen
crt_strcpy
crt_strcat
crt__kbhit
crt__getch
crt__getche
etc

The prefix was added to eliminate name conflicts with the MASM32 library and macros, and with some of the instruction mnemonics (div and fabs).
Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 17, 2007, 08:39:33 AM
OK, Thanks Michael,

It is perhaps better that I replace the crtdll with the msvcrt lib.
That's why I asked for "or replacement.
I'm not using masm a lot so I'm not at home with the masm libs.
I do like asm programming but I do need a purpose to use it.
I other words, if I have a project, I code.
And I am more into C.
My problem with asm is that I never found a good (simple) tutorial about the use of floating point math.
That's what's holding me back.

Greetings,

Ran 


Title: Re: I need crtdll.inc or replacement
Post by: MichaelW on March 17, 2007, 09:36:24 AM
The MASM32 package includes a FPU tutorial by Raymond Filiatreault that IMO is excellent. Look in masm32\tutorial\fputut.
Title: Re: I need crtdll.inc or replacement
Post by: Vortex on March 17, 2007, 09:42:45 AM
Hello Ran,

Introducing the crt_ prefix, I modified crtdll.def to avoid those conflicts :

LIBRARY crtdll
EXPORTS
crt_HUGE_dll
crt__CIacos
crt__CIasin
crt__CIatan
.
.


After, I rebuilt crtdll.lib with the new symbols prefixed with crt_ in crtdll.def :

\masm32\bin\link -lib /OUT:crtdll.lib /DEF:crtdll.def /MACHINE:IX86
del crtdll.exp
rebuildlib crtdll.lib -l4


Attached contains a working example. The size of the final import library crtdll.lib is 340 Kb.

[attachment deleted by admin]
Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 17, 2007, 06:00:40 PM
Thanks a lot Vortex,

I will put it to good use.

But Michael and Vortex, I have to ask You another question:

Using C run-time functions, is that done or not done in a masm environment if You think about speed ?
Are this functions optimised?
And if not done, do You make Your own functions or is there an existing database with optmised asm functions?

Just asking

Thanks a lot guys,

Ran
Title: Re: I need crtdll.inc or replacement
Post by: Vortex on March 17, 2007, 08:52:53 PM
I cannot guarantee you that all the C run-time functions are the best for every occasion. Hutch's masm32.lib has a lot of optimized functions. You can use MichaelW's code timing macros to evaluate the procedures.

http://www.masm32.com/board/index.php?topic=770.0
Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 17, 2007, 09:14:03 PM
He, thanks Vortex.
I'm gonna look into this.

I'm asking You all this questions because I found:

http://www.microsoft.com/msj/archive/S572.aspx

quote:

As an example, if you use sprintf in your code, try using wsprintf instead. It can prevent several KB worth of RTL code from being added to your program. Likewise, functions like strcpy can be replaced with lstrcpy. Using malloc and free in your code can add several KB of additional code and data. Consider replacing those functions with the HeapXXX equivalents (HeapAlloc, HeapFree, and so on). (For more on this subject, see my "Under the Hood" column in this issue.)

his book: http://cs.mipt.ru/index.php?id=94

Ran
Title: Re: I need crtdll.inc or replacement
Post by: Ehtyar on March 18, 2007, 08:57:29 AM
At the risk of being labeled a "purist" again, i do not include the crt in projects if i can avoid it for this very reason. In addition, i also do not like the function naming scheme, and the fact that it is simply a wrapper for functions most likely already available to your program through the system libraries.

Ehtyar.
Title: Re: I need crtdll.inc or replacement
Post by: MichaelW on March 18, 2007, 10:56:17 AM
Quoteand the fact that it is simply a wrapper for functions most likely already available to your program through the system libraries.

AFAIK there are no system equivalents for the character classification, data conversion, floating-point support, or searching/sorting functions, or all but a few of the string manipulation functions, and most of the remaining functions are, by design, much easier (and safer) to use than the system equivalents.
Title: Re: I need crtdll.inc or replacement
Post by: hutch-- on March 18, 2007, 11:06:02 AM
The MSVCRT library was made available because of demand, no-one is forced to use it but many with a C background find it familiar and convenient and get very reliable results with it. Notions of "purism" are a defacto attempt to restrict what other people choose to use on the basis of fashion. I have heard nonsense in the past that you should not use OLE, various memory allocation schemes within the OS and the like but they are all there for a reason and this offer the programmer a far wider range of choice.

In this world you choose what you use and you are not bound by the dictates of fashion in what you use.

PS : I have moved the trailing postings to the Workshop under the topic "Ehtyar on using MSVCRT" as the Campus has specific rules on assisting new members and learners.
Title: Re: I need crtdll.inc or replacement
Post by: MichaelW on March 19, 2007, 08:28:47 AM
Ran,

Considering that MSVCRT.DLL and CRTDLL.DLL are DLLs, and not a static libraries, I think it's worth pointing out another relevant statement from the same section of the MSJ article.

QuoteIf you choose to statically link these routines (as opposed to using the DLL version), you pay a price in executable size.

Title: Re: I need crtdll.inc or replacement
Post by: Ran on March 30, 2007, 12:01:20 PM
I will try this out Michael.

Ran