Author Topic: c++ versus masm  (Read 853 times)

clamicun

  • Member
  • ***
  • Posts: 347
c++ versus masm
« on: July 03, 2019, 06:12:36 PM »
Last week I "translated" one of my Masm programs into c++.
It is not better or worse but the exe file is much larger.
Probably not very well written.

Think I stay with Masm.

For those interested, here is the source compiled with dev-cpp.
My machine: Windows10 64b

TimoVJL

  • Member
  • ***
  • Posts: 408
Re: c++ versus masm
« Reply #1 on: July 03, 2019, 07:00:05 PM »
strip off debug-info and size is 918 KB
and without static crt size is 902 KB
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: c++ versus masm
« Reply #2 on: July 03, 2019, 07:36:44 PM »
TimoVJL,
This is the first c++ program I ever wrote.
I haven't the slightest idea what you mean.

TimoVJL

  • Member
  • ***
  • Posts: 408
Re: c++ versus masm
« Reply #3 on: July 03, 2019, 08:21:21 PM »
Check this in Dev-C++:
Project -> Project Options ... -> Compiler -> Linker  -> Strip executable (-s) Yes

Ctrl+H opens Project Options.

and then size is something like 920 KB.
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: c++ versus masm
« Reply #4 on: July 03, 2019, 09:13:55 PM »
ok. Thanks

jcfuller

  • Member
  • **
  • Posts: 182
Re: c++ versus masm
« Reply #5 on: July 04, 2019, 03:31:13 AM »
What is the size of your masm version?

James

clamicun

  • Member
  • ***
  • Posts: 347
Re: c++ versus masm
« Reply #6 on: July 04, 2019, 07:06:42 AM »
50% smaller

AW

  • Member
  • *****
  • Posts: 2232
  • Let's Make ASM Great Again!
Re: c++ versus masm
« Reply #7 on: July 04, 2019, 03:21:30 PM »
What is more surprising is that the background.bmp alone accounts for 778KB, this is a real miracle :badgrin:


jj2007

  • Member
  • *****
  • Posts: 9635
  • Assembler is fun ;-)
    • MasmBasic
Re: c++ versus masm
« Reply #8 on: July 04, 2019, 05:53:20 PM »
50% smaller
the background.bmp alone accounts for 778KB


Assembly rocks!
Code: [Select]
C++  exe 920 KB - 778KB =  142 KB real code
Masm exe 460 kB - 778KB = -318 KB real code

TimoVJL

  • Member
  • ***
  • Posts: 408
Re: c++ versus masm
« Reply #9 on: July 04, 2019, 06:05:01 PM »
.rsrc 909312 bytes 888 KB
.rsrc + .rdata DF000h 913408 bytes 892 KB
Code: [Select]
Dump of file DateiManager.exe

File Type: EXECUTABLE IMAGE

  Summary

        1000 .CRT
        1000 .bss
        1000 .data
        2000 .idata
        1000 .pdata
        1000 .rdata
       DE000 .rsrc
        5000 .text
        1000 .tls
        1000 .xdata
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: c++ versus masm
« Reply #10 on: July 04, 2019, 06:36:15 PM »
Thank you all,
the masm version doesn't use the bmp on the mainwindow.
That's the secret

daydreamer

  • Member
  • ****
  • Posts: 894
  • watch Chebyshev on the backside of the Moon
Re: c++ versus masm
« Reply #11 on: July 06, 2019, 04:24:09 AM »
isnt the right word you "discompiled" your masm code? :biggrin:
(like disassembler,but opposite C++ compiler)
modern C++ compiler has an advantage of not including functions/PROC that are never called and assembly has its advantages of make code small,could it be possible to have conditional assembly do the same thing make assembler code even smaller?
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
what cpu handle "press any key"? any cpu of course(from C#) :D

jj2007

  • Member
  • *****
  • Posts: 9635
  • Assembler is fun ;-)
    • MasmBasic
Re: c++ versus masm
« Reply #12 on: July 06, 2019, 04:50:55 AM »
Absolutely, daydreamer! Why don't you test it and post an example?

HSE

  • Member
  • *****
  • Posts: 1079
  • <AMD>< 7-32>
Re: c++ versus masm
« Reply #13 on: July 06, 2019, 05:18:44 AM »
...not including functions/PROC that are never called...
If you make assembly programing in a modular way, assemblers don't include functions never called.  :thumbsup:

TimoVJL

  • Member
  • ***
  • Posts: 408
Re: c++ versus masm
« Reply #14 on: July 06, 2019, 10:20:35 AM »
uasm supports COMDAT with it's own way.

a smart linker don't include unused code.
« Last Edit: July 07, 2019, 12:24:34 AM by TimoVJL »
May the source be with you