The archive mesbox.zip contains both, a C program and an assembly language program; the functionality is the same (displaying a messagebox and terminating). Both are generated with MinGW 4.6.2. The C source is compiled with: gcc -o hello.exe hello.c -mwindows. The result is a 50 KB EXE.
The assembly language source is in mesbox.s (Intel syntax); for building the program, please check out build_mesbox.bat. There's another, more sophisticated example by Vortex, which you can check here: http://masm32.com/board/index.php?topic=1140.msg10851#msg10851 (http://masm32.com/board/index.php?topic=1140.msg10851#msg10851). Thank you, Erol. :t
Gunther
Just for your information, LD breaks with Microsoft's PE/COFF specification by default: If you look into hello.exe you will find section names greater than 8, which is not allowed for PEs.
If one is interest in conform executables, he might use the well documented switch "-disable-long-section-names".
Hi qWord,
Quote from: qWord on February 08, 2013, 11:49:34 AM
Just for your information, LD breaks with Microsoft's PE/COFF specification by default: If you look into hello.exe you will find section names greater than 8, which is not allowed for PEs.
If one is interest in conform executables, he might use the well documented switch "-disable-long-section-names".
you're probably right, but I'm the false adressee. You should leave a comment for the compiler builders.
Gunther
It's interesting how much bigger the C version is. 23X
Is MinGW an optimizing compiler ?
Andy
Hi Andy,
Quote from: Magnum on February 08, 2013, 01:39:14 PM
It's interesting how much bigger the C version is. 23X
Is MinGW an optimizing compiler ?
Andy
I don't know, but MinGW is the port from the the Linux gcc for the Windows OS. It's a fairly good compiler. You should give it a try, if your system is repaired.
Gunther
Hi qWord,
Quote from: qWord on February 08, 2013, 11:49:34 AM
If one is interest in conform executables, he might use the well documented switch "-disable-long-section-names".
Fixed.
Gunther
BTW, the reason why the C version is so huge is explained here (http://mingw.org/wiki/Large_executables).
Quote from: Greenhorn on February 09, 2013, 12:41:40 AM
BTW, the reason why the C version is so huge is explained here (http://mingw.org/wiki/Large_executables).
That page is about C++, and because C++ has more language features than C, it's not surprising that C++ executables can be larger than their C counterparts. A canonical hello world C++ program, compiled with older versions of MinGW g++, could yield a ± 500 KB exe.
Greenhorn,
That is interesting info.
Even if it has the debug info, size isn't that bad.
I have seen some Visual Basic programs that were about 100x the size of an assembly program that does the same thing.
Hi Andy,
Quote from: Magnum on February 09, 2013, 03:09:38 AM
I have seen some Visual Basic programs that were about 100x the size of an assembly program that does the same thing.
that is clear, because a HLL compiler produces a lot of red band, which isn't really necessary for executing.
At the moment, I'm experimenting with as and ld under Win7 (64 bit). It's a mess, because the linker can't find the necessary libraries. There is on the other hand such a tool like Bogdan's SoAsm; it's well written, lean and under active development. But I can't re-compile the provided Linux object code, because it's for 32 bit. Bad luck. May be that Bogdan can provide a native 64 bit object file. I've asked him via PM. SolAsm seems to be a great tool and is useable under Windows and Linux.
Gunther
Using this gcc(4.7.2) distro: http://nuwen.net/mingw.html
the exe is 8,704
Of course using Tiny c the size is the same as "as" -> 2048
James
Hi James,
Quote from: jcfuller on February 09, 2013, 04:58:16 AM
Using this gcc(4.7.2) distro: http://nuwen.net/mingw.html
the exe is 8,704
is that the 64 bit Windows version?
Gunther
No. 32bit only.
I primarily use the TDM version http://tdm-gcc.tdragon.net/
It is 32/64
James
Hi Gunther,
Thanks for your example :t
Quote from: qWord on February 08, 2013, 11:49:34 AM
If you look into hello.exe you will find section names greater than 8
I am afraid this not true. Analyzing the executable with LordPE :
Section name Length of section name
.text 5
.data 5
.rdata 6
.eh_fram 8
.bss 4
.idata 6
.CRT 4
.tls 4
.debug_a 8
.debug_p 8
.debug_p 8
.debug_i 8
.debug_a 8
.debug_l 8
.debug_f 8
.debug_s 8
.debug_l 8
.debug_r 8
Thanks for explaining the -disable-long-section-names option. :t
Quote from: Vortex on February 09, 2013, 06:20:08 AMI am afraid this not true.
it is true ;)
Quote from: Gunther on February 08, 2013, 02:32:06 PM
Hi qWord,
Quote from: qWord on February 08, 2013, 11:49:34 AM
If one is interest in conform executables, he might use the well documented switch "-disable-long-section-names".
Fixed.
Gunther
Hi qWord,
Probably, I didn't make clear my statement : Size of sections names <= 8 in Gunther's example hello.exe
yes, he has rebuild the example.
Read wjr's post for an other eaxmple: http://masm32.com/board/index.php?topic=1091.msg10331#msg10331
Sorry, reading very fast all the postings. Yes, he rebuilt the example. OK.
Hi Erol,
Quote from: Vortex on February 09, 2013, 06:10:17 AM
Hi Gunther,
Thanks for your example :t
it isn't a big deal. But my 64 bit experiments are not so successful, so far.
Gunther