--- In lpc2000@yahoogroups.com, "ah_sandiego" <ah_sandiego@...> wrote: > > Can someone post a simple example of C and inline ASM in a single > file. I use the LPC2148 but any LPC board example would be helpful. > > Thanks, > AH > Depending on the compiler optimization levels, inline asm has minimal benefit for size or speed. Inline asm also limits portability for hardware and compilers. Even if you think it will never be an issue... What are you goals for this? A few bytes? A save a bit of time- 50ns? 100ns? Access to a hardware specific feature or registers? It will be difficult to beat the compiler for speed and/or density. The ARM was designed for compilers and the compilers are very good at optimization. There are several good 'c' solutions but it really depends on what you are doing. "Function Inlining" (check your compiler options) will avoid the timer overhead of calling a function. This is from the IAR C reference: "Function inlining means that a simple function, whose definition is known at compile time, is integrated into the body of its caller to eliminate the overhead of the call. This optimization, which is performed at optimization level High, normally reduces execution time, but increases code size. The resulting code might also be difficult to debug." If it is execution speed you are after, time the C function with a some io bit toggling either side of the call with an oscilloscope. Then add up the execution time of your hand written instructions and compare.* Expect better results from the compiler code. If it is size, compare the size of the C function in the map file with the size of your hand written code.* If it is access to the hardware, use the compiler extensions or pragma. *(both of these techniques introduce some inaccuracy but the results will be close. Let's not start a debate on the finer points of measurement) ~Ian
Message
Re: Example of C and inline ASM in a file?
2006-04-07 by ian.scanlon
Attachments
- No local attachments were found for this message.