What is the difference between object code, machine code and assembly code?
Can you give a visual example of their difference?
Source code, Assembly code, Machine code, Object code, Byte code, Executable file and Library file.
All these terms are often very confusing for most people for the fact that they think they are mutually exclusive. See the diagram to understand their relations. The description of each term is given below.
Instructions in human readable (programming) language
Instructions written in a high level (programming) language
e.g., C, C++ and Java programs
Instructions written in an assembly language (kind of low-level programming language).
As the first step of the compilation process, high-level code is converted into this form. It is the assembly code which is then being converted into actual machine code. On most systems, these two steps are performed automatically as a part of the compilation process.
e.g., program.asm
The product of a compilation process. It may be in the form of machine code or byte code.
e.g., file.o
Instructions in machine language.
e.g., a.out
Instruction in an intermediate form which can be executed by an interpreter such as JVM.
e.g., Java class file
The product of linking proccess. They are machine code which can be directly executed by the CPU.
e.g., an .exe file.
Note that in some contexts a file containing byte-code or scripting language instructions may also be considered executable.
Some code is compiled into this form for different reasons such as re-usability and later used by executable files.