-
In the process of single-chip microcomputer development, C language and assembly language are often used. Many people will have questions about the relationship between single-chip microcomputer and C language and assembly language, and the following will be introduced by Fuzhou Zhuoyue Education for you.
Assembly language is a symbolic language that uses text mnemonics to represent its instructions, which is the closest language to machine code, and its main advantages are that it occupies less resources and has high program execution efficiency, but different CPUs may have different assembly languages, so it is not easy to port. C language is a structured high-level language, its advantages are good readability, easy transplantation, is a commonly used computer language, the disadvantage is that it occupies more resources, and the implementation efficiency is not as high as assembly.
For the 8-bit single-chip microcomputer of the rise architecture currently used, its internal ROM, RAM, stack and other resources are limited, if the single-chip microcomputer C language is written, after a C language instruction is compiled, it will become a lot of barbed machine code, it is easy to appear that the ROM space is not enough, stack overflow and other problems, and assembly language, an instruction corresponds to a machine code, the execution of each step is very clear, and the program size and stack call are easy to control, and it is more convenient to debug.
C is a compiled programming language that combines the characteristics of a variety of high-level languages and has the functions of assembly language. The C language has rich library functions, fast operation speed, high compilation efficiency, good portability, and can directly realize the control of system hardware. In addition, the C language program has a complete modular program structure, which provides a strong guarantee for the adoption of modular program design method in software development.
Therefore, the use of C language for programming has become a mainstream of software development, as a comprehensive technology and involved in large-scale software system development of single-chip microcomputer developers should be able to master the basic C language programming.
The basic language in the microcontroller is machine language, and assembly language corresponds to it one-to-one.
In the 51 microcontrollers, there are only more than 100 instructions in assembly language, which is very simple and easy to understand and remember.
Because of its simplicity, it can be longer when writing larger programs. This is where the advantages of C come into play.
-
c C++ compilation is used by very few people!!
It is advisable to learn from assembly first and then focus on C.
-
The ** written in the high-level language is an executable program after compilation, and there are seven main processes from the high-level language to the executable.
The Seven Processes of High-Level Language Compilation:
Preprocessing, lexical analysis, syntax analysis, semantic analysis, intermediate generation, optimization, target generation.
The following is a detailed explanation of these processes:
1. Pretreatment:
Preprocess the original file, such as header files, imported modules, macro definitions, etc.;
2. Lexical analysis:
Lexical analysis is the first stage, and the task of this stage is to read the source program from left to right, character by character, and scan and decompose the character stream that makes up the source program, so as to identify each word.
3. Grammatical analysis:
The task of grammatical analysis is to break down word programs into grammatical phrases based on lexical analysis.
4. Semantic analysis:
Semantic analysis is to check the source program for semantic errors and collect type information for the generation stage.
5. Intermediate ** generation:
After the above-mentioned syntax analysis phase, some compilers turn the source program into an internal representation, which is called an intermediate language or intermediate. The intermediate generation phase takes the source program a further internal representation based on syntactic and semantic analysis, which is usually easy to generate and translate into a target, although not all languages have to go through this step.
6. Optimization:
The task of this stage is to transform or transform the intermediate ** generated in the previous stage, in order to make the generated target ** more efficient. In the optimization phase, it is not necessary to transform or transform the intermediate generation of the previous stage in order to save time and space when generating the target.
7. Target ** generation:
The task at this stage is to transform the intermediate ** into absolute instructions ** or relocatable instructions ** or assembly instructions ** on a specific machine.
-
After the source program is compiled, the target program is generated, and the target program becomes an executable program after being connected.
-
In a computer program, a program written in a high-level language is compiled to produce a program that turns the target program into a destination program.
-
Assembly language is a low-level language, which is difficult to understand, has low programming efficiency, and is prone to errors. The right C language belongs to the high.
Level language, easy to understand, fast programming, easy to port, low efficiency of program execution. However, now the running speed of the single-chip microcomputer is greatly improved than before, RAM and ROM are relatively large, and the problem of low execution efficiency of C language is no longer important, so it is better to use C language for programming.
-
Assembly language and machine language to come.
Words are one source and one correspondence.
Using the Hui Bai programming language, you can operate directly on the computer. Using the assembly DAO language, you can give full play to the programmer's imagination.
However, directly operating the computer, which has higher requirements for the ability and level of the programmer.
For beginners, let's go for advanced languages.
Using compilation software, it is possible to compile C into assembly language.
It's hard to say what it can be compiled into.
Anyway, as long as it can be used, this is the minimum requirement.
The microcontroller is composed of three modules: combinator, controller and main register. >>>More
I think my board is good, isn't it very shameless.
CS chip selection enables, and low-level chips are enabled. >>>More
Overview of microcontrollers.
1. What is a single-chip microcomputer A computer that can work should be composed of several parts: CPU (for operation and control), RAM (data storage), ROM (program storage), input and output devices (such as: serial port, parallel output port, etc.). >>>More
Because you have an error generated ::Hardware?
Procedure? >>>More