| |
| 1. |
I'm trying to use "__asm" directive with the armcc
compiler to generate some special routines, but the compiler
won't generate the instruction sequences I want. |
| Answer: |
The compiler doesn't use an assembler as part of the
code-generation process, so "__asm" does not work
as you might imagine. Instead, the requested instructions
are passed to the code generator, which applies some
optimizations. So, for example, if you write an instruction
that loads a register, this instruction will be generated
only if the compiler thinks that the value is being
used somewhere. |
|
| 2. |
Why can't I put a "__asm{ mov pc,lr }" in
my code to generate a return? |
| Answer: |
The compiler won't allow this.
Try using a C "return;". |
|
| 3. |
I want to code an SWI call, and use
"__asm{ mov r0,", etc. to set up the
registers with the proper parameters for the call.
But the compiler won't generate these MOV instructions. |
| Answer: |
They are optimized away. Try defining the software
interrupt handler via an "__swi(n)" declaration:
int __swi(0x123456) mySWI(int arg0, int arg1, int arg2, int arg3);
Then you can call it as though it were a C function:
int main(void)
{
int a;
a = mySWI(27, 14, 8, get_random_nbr());
}
This way, the compiler knows what you are trying to do
and loads the parameters automatically. |
|
| 4. |
I have coded some time-critical routines as
"__inline", but the compiler doesn't implement
them that way, it just produces an ordinary function call. |
| Answer: |
Version 2.11a of the tools would disable inlining
whenever the debug mode was specified. Version 2.5x
gives the user the option of inlining or not. |
|