in masm v9 complier exe file, why it's large than vc6 complied exe file?

Started by Tam, January 02, 2007, 07:07:00 AM

Previous topic - Next topic

Tam

in masm v9:
.586
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
.data
    szText db "I am Tam",0
    szTitle db "mams32 v9",0
.code
START:
invoke MessageBox,0,addr szText,addr szTitle,MB_OK
invoke ExitProcess,0
END START

it's 2,560 bytes in complied exe file, but in vc++ 6:

#include <windows.h>
#pragma comment(linker, "/OPT:NOWIN98")
#pragma comment(lib,"user32.lib")
#pragma comment(linker, "/ENTRY:main")   
#pragma comment(linker, "/merge:.data=.text")   
#pragma comment(linker, "/merge:.rdata=.text")   
#pragma comment(linker, "/align:512")
#pragma comment(linker, "/subsystem:windows")
void main()
{
    char Msg[] = "I am Tam";
    char Title[] = "vc++  v6";
    MessageBox(0, Msg, Title, MB_OK);
}

it's only 1,024 bytes in exe file.

so can you tell me why and what happen?

thank you!

zooba

Because the VC version has pragmas to merge the sections ("/merge:.data=.text" etc.).

If you run the linker with these options on the command line you should get the same size. 1KB is the smallest legal PE file.

Cheers,

Zooba :U

Tam

zooba, thank you very much,now I know it.
I am from china, ha ha, my english is very bad,so don't laugh at me.
I think it's  midnight now in usa, why you don't go to sleep?
I am so friendly,but my english is too badly to understand every word,so sometimes you feel I am not friendly,please excuse me.

can you tell me what's the mean 'pragmas'? I can't translate it in google and Baidu(china).

this tip is the first tip which I writed,ha ha. Is the date 1/1/2007 in usa?

thank you,everyone in this Forum!

hutch--

Hi tam,

Welcome on board. Not that minimum size matters all that much but have a look at the masm1k example in the example code, it cannot be done smaller and I doubt that VC can get it that small. Zooba is right, the minimum sized legal PE file is 1024 bytes.

Its about 7:30 PM here in Australia, thats why Zooba is still awake.  :bg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hello Tam,

Playing with the linker's file alignment option, you can get even smaller executables but there is no guarantee that they will run on every version of windows.

zooba

Quote from: Tam on January 02, 2007, 07:47:39 AM
I think it's  midnight now in usa, why you don't go to sleep?

As Hutch said, here in Australia it's a slightly earlier hour (or later in fact, since we're a day ahead). In any case, midnight isn't that strange an hour for me no matter what country I'm in :bg

Quote from: Tam on January 02, 2007, 07:47:39 AM
can you tell me what's the mean 'pragmas'? I can't translate it in google and Baidu(china).

A 'pragma' in this context is a special instruction on how the code should be compiled. They are usually advanced optimisations and you can get by just fine without using them (especially in VC, since you get lots of nice dialog boxes that do the same things :wink )

Cheers,

Zooba :U

Tam

QuoteIn any case, midnight isn't that strange an hour for me no matter what country I'm in
I think so, ha ha.
QuoteA 'pragma' in this context is a special instruction on how the code should be compiled. They are usually advanced optimisations and you can get by just fine without using them (especially in VC, since you get lots of nice dialog boxes that do the same things  )
yes, I know a little about it in head file of vc++.

thank you for answering my question!

I think www.masm32.com is in usa before I visit it yesterday, but I check it in this morning, It was in England(right?).

ha ha, hutch ,Vortex,Zooba, Are you australia? I think that you are american before yesterday!

hutch--

 :bg

Your guesses are not so good, Vortex is from Turkey where zooba and I live in Australia. We have members from around the world so it may not be easy to guess where they come from.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php