Clock not running (was Re: RTEMS4.7 and its tool chain (Re: powerpc mvme5500 clock off by factor of 150))

Till Straumann strauman at
Wed Mar 9 17:43:33 UTC 2005

Joel Sherr wrote:

> Till,
> Could you please educate us on what the & does?

Again - from the GCC info pages:

"    Unless an output operand has the `&' constraint modifier, GCC may
allocate it in the same register as an unrelated input operand, on the
assumption the inputs are consumed before the outputs are produced.
This assumption may be false if the assembler code actually consists of
more than one instruction.  In such a case, use `&' for each output
operand that may not overlap an input. "

>   It looks like
> there may be more to fix.  :(

Could be - I already had a coarse look at libcpu/powerpc, 
and it doesn't look too bad.

- ASM with only a single statement are OK
- multi-statement ASMs with no output operands are OK
- multi-statement ASMs with no input operands are OK

==> you should use "=&" for output operands in multi-statement
        ASMs that also have input operands unless you know what you
        are doing.

Sidenote: anyone using 'asm' better know what they are doing. E.g,
many PPC instructions treat reg. 0 special, i.e., they don't really use
reg 0 but a literal 0. For such instructions a simple "r" constraint is
inappropriate since the compiler might allocate r0 which would not
be what you want [use "b" in this case]!

-- Till

> --joel
> Peter Dufault wrote:
>> On Mar 9, 2005, at 7:15 AM, Joel Sherrill <joel at> wrote:
>>> cpukit/score/cpu/powerpc/rtems/score/cpu.h has these:
>>> #define PPC_Set_decrementer( _clicks ) \
>>>   do { \
>>>     asm volatile( "mtdec %0" : : "r" ((_clicks)) ); \
>>>   } while (0)
>>> #define PPC_Get_decrementer( _clicks ) \
>>>     asm volatile( "mfdec  %0" : "=r" (_clicks) )
>>> Note that there is no & in the get.  Even the get and set timebase
>>> register don't have them.  Is this right?
>> I had checked that they matched before.  It fixed my problem.  I 
>> don't know if it is a gcc "feature" in 4.0 or what, and today I don't 
>> have time to think about it.  I've been up since Till found that 
>> problem last night getting my application running, and I'm planning 
>> to try things out at the customer site in a few hours.
>> Again, Till gets my "Hero of the Day" award.
>> Peter
>> Peter Dufault
>> HD Associates, Inc.

More information about the users mailing list