Assembly and c-language - a comparison of filesizes -


I made two Hello-World programs - using the debugger in CMD in an x86 assembly, in the second c-language.

As the assembly language gives the CPU very precise instructions, it is not surprising that executable file captures fewer bytes in memory compared to executable C-files. But I was surprised that the difference is really huge: put it down:

  Hello World in x86 assembly: 30 bytes Hello world in C-language: 102 KB  / Pre> 

This is - The program has 3400 assembly assembly programs.

I first thought that in this context, it can be explained by adding header file as stdio.h but without compiling it, the file-size should be reduced to only 95 KB. Gaya.

So - I have a question - is that the assembly file is quite heavy in the C-file bytes? Could it be a definite DL-file that it is executable?

x86 assembly code:

  jmp 115 db 'hello world! $ '-A 115 mh AH, 09 mop dx, 102 int 21 int 20   

C-code:

  # Include & lt; Stdio.h & gt; Int main (zero) {printf ("Hello World!"); }   

C-program minimum option

This overhead is probably due to the compiler default runtime-library, because you are using it to call printf () . Note that printf () is the way a function more capable than the one you are calling. All capacities of the course mean that there are more codes in it. You can put printf () to with () .

Trying to switch I'm not saying that printf () is 102 KB alone, it's probably far away from it, but you also get the entire library It can support the code (init / de-init, exit-handlers, and so on) and not only a function.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -