Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how a source code is converted into 1's and 0's?

computers do not understand anything except one's and zero's.But I want to know the details how a source code or an instruction set is converted into 1's and 0's.Is the exe file only contains 1's and 0's?

like image 774
Radheshyam Nayak Avatar asked Dec 08 '22 01:12

Radheshyam Nayak


2 Answers

Each type of operation in a microprocessor's instruction set is specified by an opcode, which is represented as a pattern of 1s and 0s. A compiler or interpreter translates code in a source language to machine code made up of those instructions.

For example, take this code, where a variable, x, is assigned the value of 50:

x = 50;

The compiler might translate that to the following assembly language, where the AX register (for the x variable) is set with the value, 50 (in hexidecimal), using the MOV instruction:

mov ax, 0x32

If the opcode for MOV was 0xA0 and the code for the AX register was 0xB then the machine code, in binary, would look like this:

10100000 00001011 00110010
like image 56
Mark Cidade Avatar answered Jan 18 '23 22:01

Mark Cidade


You need to research Compilers

like image 38
Chris Thompson Avatar answered Jan 18 '23 22:01

Chris Thompson