Key points of embedded system program development based on ARM (VI) - Skills for developing efficient programs Industry Technology & Information I ND US TR Y TECH & I NF O Key points of embedded system program development based on ARM (VI) - Skills for developing efficient programs ■ ARM China Fei Zheping Developing efficient programs involves many aspects, including programming style, algorithm implementation, and special optimization for targets. This part mainly introduces several points to pay attention to in program development based on the characteristics of ARM architecture. To perform sign extension in a 32-bit register, for signed variables, two instructions, logical left shift (LSL) followed by arithmetic right shift (ASR), are required to complete the sign extension; for unsigned variables, a logical and (AND) instruction is required to clear the sign bit. Therefore, it is most efficient to use 32-bit int or unsigned int local variables. int wordinc (int a) { return a + 1; } short shortinc (short a) { return a + 1; } wordinc ADD a1,a1,#1 MOV PC,LR shortinc ADD a1,a1,#1 MOV a1,a1,LSL #16 MOV a1,a1,ASR #16 MOV PC,LR1Variable definition Although variable definition is very simple, there are many things worth noting. Let\'s take a look at the following example: char short char int a; b; c; d; char char short int a; c; b; d; The four variables defined here are all the same, but the order is different, which leads to different data layouts in the final image, as shown in Figure 1. Obviously, the second method saves more memory space. char charinc (char a) { return a + 1; } charinc ADD a1,a1,#1 AND a1,a1,#&ff MOV PC,LR……
You Might Like
Recommended ContentMore
Open source project More
Popular Components
Searched by Users
Just Take a LookMore
Trending Downloads
Trending ArticlesMore