I read that compilers convert the high level language source code into machine code written in 1s and 0s.
I want to know how a whats the machine code equivalent of a hello world program i have written in c++.
I am not a just starting to learn cpp now(because you might get the idea from the hello world reference.) I have reached the standard template library now. Still Studying...
Is there any way to have a look at the machine code? Can you give my any simple high level source code and its machine lang. equivalent.
Is there any way to have a look at the machine code?
Your compiler probably has options to output a list file with the source code listing and possibly with assembly language interspersed. For your early reading, you may want to reduce your compiler's optimization settings.
Most compilers have a command line option to output the assembly code for what they generate. Assembly code is still an ASCII text file but the instructions correspond one-to-one with the machine code. With g++, the option is -S.
You will need to learn about the architecture of the CPU you're using. You can probably get some of this from wikipedia.
generated an output listing of 1651 lines when the source, assembly, and machine code are all selected for output when using Microsoft Visual Studio C++ 2010.
I have cut the following listing from the output log file. It is concentrated on the lines of the main() function.