How does the source code convert to 1 and 0?

computers understand nothing but one and zero. But I want to know more about how the source code or instruction set is converted to 1 and 0. If the exe file contains only 1 and 0?

+3
source share
4 answers

Each type of operation in the instruction set is defined by an operation code, which is represented as a pattern 1s and 0s. A compiler or interpreter translates the code into the source language machine code composed of these instructions.

For example, take this code where the variable is set xto 50:

x = 50;

, AX ( x) 50 ( ), MOV :

mov ax, 0x32

MOV 0xA0, AX 0xB, :

10100000 00001011 00110010
+6

+4

. A.exe , 0 1 ( )

, SUM, MOV .. , CPU. - 2 + 3 -, CPU (SUM ..).

, , , 2 + 3, ( ).

+2

, Assembly, . .

Each high-level instruction (in your programming language) is associated with Assembly instructions. These Assembly instructions can be highly optimized (hence, GCC and other compilers, optimization flags).

You might want to read http://computer.howstuffworks.com/bytes.htm

0
source

Source: https://habr.com/ru/post/1762629/


All Articles