Archived

This topic is now archived and is closed to further replies.

TanTheta

VC++ 6 or ASM optimizations

Recommended Posts

TanTheta    122
This is just something I came across and I was wondering if someone could tell me why this happens : I created a C program in VC++ 6 which just displays a plain window.I used the WIN32 Api,no MFC or anything else.I defined #define WIN32_LEAN_AND_MEAN and included windows.h. In WinMain,I initialize the WndClass structure,register the class and create the window using CreateWindow. Then the message handling loop and i return. Just a plain generic WIN32 application.Now,I build the exe,optimizing it for size.The file created is of 36 kb. Next,when i wrote the same program in ASM(using MASM 6),I got an exe of size 5.5 kb(6 times less!).The only diff is that in the ASM prog i used CreateWindowEx as (apparently)MASM 6 has no declaraton for CreateWindow in its headers. I have heard that VC++6 is the best optimizing compiler for the Win32 platform and had expected the two filesizes to be the same.Could anyone explain why they are so different? Thanks!

Share this post


Link to post
Share on other sites
Gladiator    127
windows.h is pretty big to tell you the truth... and you can''t compare ASM programs to C/C++ programs in any way. ASM will always be smaller and faster since it''s the native tongue language of the computer, and is considered low-leve, whereas C++ is a high-level language. Including libraries in your programs, will make your program larger in size as the number of included files increases.

-------------------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites
Theses    122
changing the linking option from static to dynamically should shave a ton off the file size
in other words go to
project
settings
C/C++
category: code generation
use run-time library: multithreaded dll

Edited by - Theses on July 19, 2000 2:22:34 PM

Share this post


Link to post
Share on other sites
TimSmith    122
I would take a look at the map file generated by VC6. I would bet that most of that space is bootstrap code for C. If you generated an ASM listing for your C main, I would imagine that you will find that the ASM produced by the compiler is very ''reasonably'' sized.

Tim

Share this post


Link to post
Share on other sites