Computer programs written in higher-level languages like Python or Java are human-friendly and easy to understand. But, a computer CPU does not understand high-level languages. So, the high-level language needs to be translated into machine code.
A machine code instruction is a string of 0’s and 1’s. It can be understood by a computer CPU. A machine code instruction instructs a CPU to perform certain tasks like loading data into registers, storing data into a memory location, performing some arithmetic or logical operation, etc. These machine code instructions can be understood by a computer CPU, but they are not human-friendly. They cannot be read by humans so easily. So, we need assembly language for this purpose.
In assembly language, each machine code instruction is replaced with symbolic names. As a result, they are much more human-readable.
Now, when we compile a program written in a high-level language, we generate binary. But, the generated binary may not be ready to run by the computer CPU. If the program written in high-level language uses headers or libraries, those headers and libraries need to be linked with the generated binary. The binary file that is yet to be linked with the headers and libraries is called an object file.
An object code is written in machine code or in some code using an intermediate language such as Register Transfer Language (RTL). A linker takes object code as input, links it with required libraries and headers, and generates machine code that can be loaded into system memory and executed.
The machine code that can be readily loaded into system memory and executed, is called an executable. A loader takes an executable code and loads it into system memory. It also initializes CPU registers, and stacks, and prepares the code for execution.






0 Comments