Hi Georg,

I haven't tested this, but to embed the assembly language you need something like the following. If you look in the mspgcc documentation you will find some information about this. If you look in the GNU GCC documentation you will find some more. However, this area is not as well documented as it might be, with clear examples, etc. Figuring out exactly how to use those dependency fields is not easy.

Regards,
Steve

unsigned char reverse(unsigned char b)
{
 unsigned char tmp = 0;

 for( i=0; i<8; i++ )
 {
   __asm__ (
           " rrc.b  %[b] \n"
           " rrl.b   %[tmp] \n"
       : [tmp] "+r"(tmp)
       : [b] "r"(b));
 }
   return tmp;
}

Georg Ritter wrote:

Good morning!

I'm looking for a proper implementation of a bitwisereverse function of a byte (1010 0001 becomes: 1000 0101). I want to replace an ugly and clumpsy function I used in testing.

I would like to write smth like:

unsigned char reverse(unsigned char b)
{
  unsigned char tmp=0;
  for( i=0; i<8; i++ )
  {
    // RRC.B of b
    // RRL.B into tmp
  }
    return tmp;
}

There's no real "C" way of doing it, isn't it? So what could the inline asmbly line for that look like. I never used it before, and it's tricky and documents didn't enlighten my too much. So my versions either didn't compile or didn't work.

Or is there a smaller (in terms of code size) way of doing the reversion (hacker contest ;-) )?

Greetz,

    Georg



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users




Reply via email to