Programming languages like JavaScript or Python are high-level programming languages. They are human-readable and easy to understand. But, a computer processor does not understand high-level programming languages. It understands machine language instructions.
A machine language instruction is a string of 0’s and 1’s. It is used to control the Central Processing Unit (CPU) of a computer. Each machine language instruction instructs the CPU to perform some tasks like load data to a register, store data to a memory location, jump to a specific memory location, perform some arithmetic or logical operation, etc.
But, as these machine language instructions consist of strings of 0’s and 1’s, they are not very human-friendly. Assembly language is a symbolic machine code where each machine code instruction is replaced with symbolic names. As a result, assembly language code becomes much more human-readable than machine code.
When we compile a program written in a high-level programming language, the code first gets translated into assembly code. An assembler translates the assembly code into machine code. The machine code can be interpreted by the CPU, but it is not yet ready to run. To run the generated machine code, we need to link the generated machine code with libraries and headers. A linker does the job. A linker takes the generated machine code as input, links it with required libraries, headers, etc., and generates a machine code that can be loaded to memory. A loader then loads the machine code to system memory, initializes the registers, creates stacks, and then the machine code gets executed.
Please note that a high-level programming language is portable across multiple computer architectures. But, as assembly code is strongly related to machine code and machine code depends on a CPU’s instruction set architecture, assembly language is specific to computer architecture.






0 Comments