• ### Announcements

#### Archived

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

# disassembled a simple program

## Recommended Posts

Ciner    122
Can someone please explain to me why this same code in asm is equal to around 12000 lines? Compiled in release mode in VC++ 6 and disassembled w32dsm. #include <iostream.h> main() { cout << "test\n"; return 0; }

##### Share on other sites
it may be including the lines from iostream.h ...possibly...i really dont know

##### Share on other sites
Valderman    513
There''s a lot of startup and shutdown code involved, as well as code from various statically linked libraries.

"For crying out loud, she has fishes coming out of her head on either side. How can you find this hot?!"

"If anyone sees a suspicious, camouflaged factory being carried across the desert, they should report it immediately."

##### Share on other sites
glassJAw    128
"cout" is a lot more complicated than it looks

##### Share on other sites
smart_idiot    1298
Unrelated to the original topic. . .

Don''t use #include <iostream.h>, it is deprecated. Use #include <iostream>.

##### Share on other sites
Guest Anonymous Poster
When I try <iostream> I get:
error C2065: ''cout'' : undeclared identifier
error C2297: ''<<'' : illegal, right operand has type ''char [6]''

##### Share on other sites
Colin Jeanne    1114
quote:
Original post by Anonymous Poster
When I try I get:
error C2065: ''cout'' : undeclared identifier
error C2297: ''<<'' : illegal, right operand has type ''char [6]''

That is because the book/tutorial you are using is old and useless. Get something new.

Try reading tutorials from this site

Qui fut tout, et qui ne fut rien

##### Share on other sites
invader X..i actually think its the originaly problem..those were the exact problems i was getting when i tried to run my console programs as win 32 apps...so i think if he just made it a console application...he should be fine (now...thats assuming hes using visual studio..i have no clue how the otehr ones work)

##### Share on other sites
dwarfsoft    1229

-Chris Bennett of Dwarfsoft - The future of RPGs GPA Thanks to all the goblins in the GDCorner niche

##### Share on other sites
dwarfsoft    1229
Just wrote an equivalent program without all the includes, and it is still 16KB of compiled windows console code.

Using the techniques that were learned in those articles I got the compiled size down to 521 bytes. It isn''t exactly the same program, but has the same concept.

#include <stdio.h>void mainCRTStartup(void){	char*p = "test\n\0";	while((*p) != 0)_fputchar(*(p++));	_fgetchar();}

There are variously nasty coding habbits in that source, like losing the pointer to the start of the line (originally pointed to by "p")

Noted that the required Library to use for _fputchar and _fgetchar is MSVCRT.LIB. This must be linked with the program (after we have checked the "Ignore all default libraries").

For most people this excercise is completely useless, as we want proper coding techniques. But this post is just a point about how much unnecessary crap is actually included in compiled programs MSVC for recent versions of Windows. Our code is getting majorly bloated.

##### Share on other sites
dwarfsoft    1229
quote:
invader X..i actually think its the originaly problem..those were the exact problems i was getting when i tried to run my console programs as win 32 apps...so i think if he just made it a console application...he should be fine (now...thats assuming hes using visual studio..i have no clue how the otehr ones work)

Actually, under MSVC console I get the same errors.

##### Share on other sites
To fix the thing about cout not being defined, do this

#include <iostream>using namespace std;int main(){     cout << "test" << endl;     return 0;}

or

#include <iostream>int main(){     std::cout << "test" << std::endl;     return 0;}

Michael Bartman