Conversion rules of C51 function names and assembler names AfterĬ51 program modules are compiled into object files, the function names in them will be converted into different function names according to the nature of their definitions, so in C51 When calling each other with the assembler, the assembler must obey this conversion rule for function names.
If the SRC instruction is not used during compilation, the assembly code in C51 will be ignored by the compiler.ģ.3 Interface between C51 and assembled modulesġ. Using this method, you can embed assembly statements with #pragma? Asm and #pragma? Endasm anywhere in the C51 source code. Will be embedded in the assembly statement source file into the project file to be compiled, point the cursor to this file, select the right-click menu "option? For? File? 'Asm.c'", the property sheet "properties" "Generate? Assembler? SRC? File" and "Assemble? SRC? File" are set to bold "√", remove the "Link? Public? Only" "√", and then compile. Keil C51 compilation environment related settings Method one: add “asm” pre-compiled instruction directly before each assembly statement in the function body. Inserting online assembly language to change the assembly environment or may change the value of the C variable may cause serious mistake. Online assembly provides the ability to directly read and write hardware, such as read and write interrupt control permission registers, etc., but the compiler does not check and analyze online assembly language. Module usually refers to the insertion of assembly code inside the C function, also known as the embedded assembly statement. On the other hand, in the process of program development with assembly language as the main body, if complex mathematical operations are involved, it is often necessary to use the arithmetic library functions and powerful data processing capabilities provided by C51, which requires calling C51 functions in assembly. However, the strict use of assembly program design in some timing requirements has higher efficiency, so it is required to call some subprograms written in assembly language in the C program. Usually use C51 to write the main program. Third, C51 and ASM mixed programming technology NOREGPARMS: Parameter passing is always done in this data segment, and the program code is compatible with earlier C51 versions. NOAREGS: Absolute register access is not used, and the program code is independent of the register set in this way. OPTMIZE (SIZE): The common "C" operation is replaced by a subroutine: the program code length is compressed.
PEEPHOLE optimization: As long as it can save storage space or execution time, complex operations will be simplified.Īccess optimization: Constants and variables are directly included in the operation.ĭata coverage: The data and displacement of the function are marked as OVERLAYABLE and are overwritten with other data and bits by L51.ĬASE / SWITCH optimization: The SWITCH / CASE statement is optimized as a jump or a series of jumps. Global common sub-form elimination: same sub-expression or address calculation (multiple occurrences in the same function) will It is recognized and will be calculated only once whenever possible. Parameters are passed through registers: up to three parameters can be passed in registers Register variable: as long as It is possible that automatic variables and parameters are placed in registers Jump optimization: jump to the final target address to improve program efficiency ĭead code elimination: non-executable code (dead code) can be removed from the program All optimization methods of C51 are as follows:Ĭonstant folding: occurs in an expression or address calculation Several constant values in are combined into one constant
The user can choose 6 optimization levels.
The default serial port is the output device, but you can modify LCD display.Ĭ51 can optimize the code prepared by even experienced programmers. You can modify all the library functions by changing the two modules of the existing hardware input and output structure, and you can also quickly and quickly construct functions such as "printf" and "puts" system. Second, C51 compiler library and code optimization technologyĬ51 compiler contains 6 different compiler libraries, such as Table 12-2-1 can be optimized according to different needs, C51 compiler contains library modules, all have source code, they can be used for hardware-related modify. If the user defines a font file "kzk.h", use #include "hzk.h" at the beginning of the source file, and then you can use the font in the source program.