Machine Language or Binary Language/Code
What is Machine Language?
Machine language is a low level programming language. Machine Language is a combination of one’s and zero’s (1’s and 0’s). Machine language/code also called as the Binary language as it only have binary numbers i.e 0’s and 1’s.
The computers only understands the 0’s and 1’s ( Binary Values ).
All the programs which are written in high level language programming or Assembly language need to be converted into the Binary code, So that the computer can understand and execute the program.
Machine Code is bunch of 0’s and 1’s. So It is almost impossible to do programming in machine language. It is very difficult to read and understand.
The Machine Code is also the Hardware Dependent. Means if we write any program on machine language which can’t be run on other hardware platforms. So Machine code is not portable.
All the day to day content like Videos, Images and Applications all will be converted into the Machine code. So everything we saw on the computer screen need to be converted into the machine code then only the CPU can understand it and provide the desired output.
The Machine language is everywhere, But fortunately we don’t really need to learn or understand. We have the converters like compilers and Assemblers, etc, Which will do all the heavy lifting for us by converting all our program into machine code for us.
Let’s see how the machine language code actually look like. We will write a program in C language and then convert it into the machine code i.e executable file. Then we will observe the executable file contents.
C Program to Add two numbers:
// Take two input numbers
int x = 10, y = 20;
// Add two numbers and store result into variable 'sum'
int sum = x + y;
// Display the result
printf("Sum of %d and %d is %d \n", x, y, sum);
Now compile this program using the GCC compiler to create an executable file.
We saved our program with sum.c name and above gcc sum.c command will compile the program and generates the executable file named a.out
Machine Language Code Example
The a.out file is Machine language code or Binary language code. So Let’s open the a.out file
Here are the contents of a.out file
As you can from the output, The Machine code is combination of 0’s and 1’s.
In the above Machine code, The binary values are represented in the Hexadecimal format. That is the reason we are seeing the symbols like 4F or 5F etc.
The 4F is equal to 01001111
So don’t confuse as the output is not in the binary format. It is just displayed in Hexadecimal representation.
We have discussed Machine or Binary Language. We also saw where we use the binary language with examples.
Also READ :
- Start Here – Step by step tutorials to Learn C programming Online with Example Programs – SillyCodes
[…] Machine Language Or Binary Language […]
[…] the previous article, We have discussed about the what is Machine Language. Now in this article, We will look at the features of C […]
[…] is a language that consists of instructions designed for the computers.Processors only understandmachine code as it reaches in two series of 0’s and 1’s, also known as binary data. Machine code is […]