Data types and compilation process in the computer

1. The use of Visual Studio Code

1. How to open VS CODE:

(1) It can be opened directly in the graphical interface

(2) Use code + path in the compiler

2. Ctrl + Shift + L to automatically align

3. Ctrl + S to save

2. Numerical data (conversion between bases)

123=1*100+2*10+3*1

=1*10^2+2*10^1+3*10^0

Octal: 0 1 2 3 4 5 6 7

Every three bits of binary can represent one bit of octal

Binary: 111

Octal: 7

One bit of octal can represent three bits of binary

Hexadecimal: 0 1 2 3 4 5 6 7 8 9 ABCDEF every hexadecimal one

Every four binary digits can represent a hexadecimal digit

Binary: 1111

Hexadecimal: F

practise:

Convert binary 0111 1110 to octal, decimal and hexadecimal.

Octal: 176

Decimal: 126

Hex: 7E

0111 1110

Octal: 176

Hex: 7E

Decimal: 0+1*2^1+1*2^2+1*2^3+1*2^4+1*2^5+1*2^6+0*2^7=126

Convert decimal 100 to binary:

100/2=50...0

50/2=25...0

25/2=12...1

12/2=6...0

6/2=3...0

3/2=1...1

1/2=0....1

1100100

3. Non-numerical data

The concept of data in the computer is broad. In addition to the numerical data mentioned above, there are also text, symbols, images, language and logical information in the computer, because they also exist in the form of 0 and 1. So it becomes non-numeric data

Character data mainly refers to numbers, letters, general symbols, control symbols, etc., which are converted into a binary code form that the computer can recognize in the machine. A code commonly used internationally is the American National Standard Code for Information Interchange, abbreviated as ASCII

Quoted characters are characters, such as 'A', '1'

ASCII:American Standard Code for Information Interchange

The difference between "0", '0', 0 and '\0'?

"0" String 0

'0' character 0

0 number 0

'\0' null character

4. Compilation process

Preprocessing: gcc -E hello.c -o hello.i to get the preprocessing file, where -E means only precompilation.

The source file will be generated by the compiler in the pre-compilation stage. i file, which mainly deals with the pre-compilation instructions starting with "#" in the source code file. Such as: macro definition expansion, inserting the included file into the position of the compilation instruction, etc.

Compile: gcc -S hello.i -o hello.s to get the assembly file, where -S means to generate the assembly file.

Compilation is the process of syntactic analysis, lexical analysis, semantic analysis and optimization to generate corresponding assembly code files after the preprocessed files. This process is the core process of the entire program construction and is also the most complicated part.

Assembly: gcc -c hello.s -o hello.o, where -c means only compiling but not linking. Convert the assembly code file into an instruction file that the machine can execute, that is, an object file. It can also be used directly: gcc -c hello.c -o hello.o After preprocessing, compiling and assembling, the target file is directly output

Link: -o output_ filename , make sure the name of the output file is output_filename, and this name cannot be the same as the source file . If this option is not given, gcc will give the default executable file a.out.

 
 

Guess you like

Origin blog.csdn.net/qq_52049228/article/details/129878312