How can I make the generated code as efficient as assembly when programming?

Publisher:岭南布衣Latest update time:2015-03-12 Source: laoguKeywords:Programming Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
If you use C language to program, it is unlikely that the generated code has the same efficiency as assembly language 1:1.

C language commands must be compiled by the compiler to be recognized and executed by the hardware. Compilers are divided into front-end, middle-end and back-end.
The front-end deals with programs written in various computer languages, and the back-end is connected to the basic instruction set of the processor.
Therefore, if you use C programming, to achieve the highest efficiency, it is best to understand the C compiler used.
First, test the number of assembly language statements corresponding to each C language compilation, so that you can clearly know the efficiency.
In the future programming, use the statements with the highest compilation efficiency, so that you can ensure that the same function and different C programs have the highest compilation efficiency when programming the single-chip microcomputer C.
However, there are certain differences between different C compilers. The code length and execution time of an excellent embedded system C compiler are only 5-20% longer than the same function written in assembly language,
so the compilation efficiency of C compilers from different manufacturers will also be different.
Keywords:Programming Reference address:How can I make the generated code as efficient as assembly when programming?

Previous article:How to measure the stability of the system when developing a single-chip microcomputer system
Next article:What are the problems of software anti-interference in embedded development? How to solve them?

Recommended ReadingLatest update time:2024-11-16 13:33

Danlaw and Code 3 jointly develop fully integrated V2X system to improve emergency vehicle safety
(Photo source: Danlaw official website) According to foreign media reports, Danlaw, a connected car technology company, will showcase its latest V2X solution safety applications. Danlaw has partnered with Code 3, a supplier of emergency vehicle lighting and sound solutions, to develop a fully integrated V2X syste
[Automotive Electronics]
Danlaw and Code 3 jointly develop fully integrated V2X system to improve emergency vehicle safety
Detailed explanation of data idata xdata code in keil c51
51 single-chip microcomputer adopts Harvard structure. The memory space addressing has overlap. Different variables can be defined on different buses (referred to as bus domains in this article, or domains for short). Several domain modifiers such as data, idata, xdata, and code are defined in keilc51. These modifiers
[Microcontroller]
Detailed explanation of data idata xdata code in keil c51
Detailed explanation of the difference between data, xdata and code of 51 MCU
dATa: Fixed to the first 128 RAM from 0x00 to 0x7f, can be directly read and written with acc, fastest speed, and the smallest generated code. idATa: Fixed to the first 256 RAM from 0x00 to 0xff, the first 128 are exactly the same as the 128 of dATa, just because of the different access methods. idATa is accessed in
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号