size of executable files?

余生长醉 提交于 2020-01-11 10:04:38

问题


I created a very small code to add two integers and save the result in another variables, both in assembly language and c language. code in assembly cost me 617 bytes but code in C took 25k bytes!! why there is a huge difference? Also how can I view the assembly symbolic instructions for C code I wrote?


回答1:


High level languages have a certain amount of overhead. While in assembly all you have is exactly what you say.

The overhead you are seeing in this case is likely the static binding of standard components, such as printf. Likely an include statement added these.

If you want to see what your output is like you will need a dissembler. Here is the documentation for the NASM dissembler if you wanted to take a look at one.

You can avoid some of this overhead by not including anything and instead implement the functionality in a fashion similar to how you did in assembly.



来源:https://stackoverflow.com/questions/5535188/size-of-executable-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!