Hi, I have the following problem:
I am trying to set an immediate value in an inline assembler directive like this:
template <int PMC> class PerformanceMonitor { public: inline void freezeCounter() { asm ("mtpmr %0, %1" : : "i" (PMLCa), "r" (1 << 31)); } private: const int PMLCa = PMC + 128; };
This leads to the following:
asm operand 0 probably doesn't match constraints
My question is: why does this happen and how can I set PMLCa so it can be used there?
In the gcc-4.8.2 manual (Simple Constraints - Using the GNU Compiler Collection (GCC)) it is written that:
So it should be possible to use a constant as an immediate value in inline assembler or am I wrong?
(Note: if i replace PMLCa in line 5 with PMC it works)
Thanks in advance.
Regards
Clemens
(I'm working bare metal on a P4080DS, used compiler in CodeWarrior is "PowerPC EABI e500mc C++ Compiler" (gcc-4.8.2-Ee500mc-eabi))
Hi,
I tried your code snippet in a Bareboard project wizard for P4080, in CodeWarrior 10.4, with also gcc-4.8.2-Ee500mc-eabi, the build is no problem... I put it in the above of main()...
Ok I also got it to work.
I just changed optimization from -O0 to -O3.
It seems to work with all optimization levels except for O0.
Thanks for your testing.