[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

m68k/cc issue (was Re: gettimeofday seconds rollover problem?)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Till,

Till Straumann schrieb:
> Someone (don't have enough m68k knowledge in my cache
> behind my eyes) should be answer this. It's not
> rocket science:
> 
> Do the enable/disable inlines potentially modify
> a bit in the 'cc' that the ABI declares non-volatile?

yes, the condition codes CC are part of the m68k status register SR (the
lower 8 bits). In the _enable macro the SR is restored to the value it
had before the "_disable" macro was called, so in fact the "_enable"
macro changes the CC.

It is sufficent to mark the CC clobbered in the enable macro, and I
don't think it will cost any performance at all, since we all agree that
it is not really nedded right now ;->

> 
> BTW: I couldn't help playing with this and it seems
> that 'cc' is ignored anyways on m68k and on powerpc
> (I know that on the powerpc you must explicitely
> list the non-volatile crX in the clobber list if you
> modify them from an asm, 'cc' is definitely ignored)
> 
> void blah()
> {
> asm volatile("":::"cc");
> }
> 
> 
> is compiled (m68k-rtems-gcc -m528x, version 4.0.2) into
> 
> Disassembly of section .text:
> 
> 00000000 <blah>:
>    0:   4e75            rts

In this situation I don't expect it to have any effect, you are right.
But think about this piece of code:

volatile int a;
int b;
volatile c;
void blahblah(int a)
{

  b = a+3;
  asm volatile("":::"cc");
  if (b == 0){
    c = 1234;
  }
  else {
    c = 4321;
  }
}

In this construct, the condition codes are automatically evaluated at
the addition instruction (a+3). The compiler would possibly not generate
a new "compare" instruction to check, whether b equates to zero. But the
"CC" in the clobber list will enforce this.

wkr,
Thomas.

> 
> 
> 
> FWIW
> 
> -- T.


- --
- --------------------------------------------
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de
PGP public key available at:
     http://www.imd-systems.de/pgpkey_en.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEA/gAwHyg4bDtfjQRAsIBAKCZttb6rxS8TRP7WYgwtD/QAt50PgCfZdOD
sd2Lj7mLRQk1UROuvdgm32Y=
=lJex
-----END PGP SIGNATURE-----