文本描述
Efficient C Code for Eight-Bit MCUs
The 8051, 68HC11, and PIC are popular MCUs, but they aren’t necessarily easy to program. This article shows how the use of ANSI and compiler-specific constructs can help generate tighter code.
Getting the best possible performance out of an eight-bit microcontroller C compiler isn’t always easy. This article concentrates mainly on those microcontrollers that were never designed to support high-level languages, such as the 8051 family, the 6800 family (including the 68HCll), and the PIC line of microcontrollers. Newer eight-bit machines such as the Philips 8051XA and the Atmel Atmega series were designed explicitly to support HLLs, and as such, may not need all the techniques I describe here.
My emphasis is not on algorithm design, nor does it depend on a specific microprocessor or compiler. Rather, I describe general techniques that are widely applicable. In many cases, these techniques work on larger machines, although you may decide that the trade-offs involved aren’t worthwhile.
Before jumping into the meat of the article, let’s briefly digress with a discussion of the philosophy involved. The microcontrollers I mentioned are popular for reasons of size, price, power consumption, peripheral mix, and so on. Notice that “ease of programming