avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-b


From: Royce Pereira
Subject: Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?
Date: Fri, 04 Nov 2005 12:04:16 +0530
User-agent: Opera M2/9.0 (Win32)

hI,

On Fri, 04 Nov 2005 11:41:35 +0530, Vincent Trouilliez <address@hidden> wrote:

So that's indeed about 20 times faster. Although I still don't get why
it can't just use one single SBRC/S instruction instead of these 4 cp or
--------------------------

Have you tried creating a structure of single bit variables like:

typedef unsigned        word
typedef unsigned char   byte
//Above is for my conenienience only..

typedef volatile union  //reserve 2 bytes to be used as flags.
            {
               word asword;
                        
               struct
                  {
                     byte B0: 1;
                     byte B1: 1;
                     byte B2 : 1;
                     byte B3 : 1;
                     byte B4 : 1;
                     byte B5 : 1;
                     byte B6 : 1;
                     byte B7 : 1;
                     byte B8 : 1;
                     byte B9 : 1;
                     byte B10 : 1;
                     byte B11 : 1;
                        //etc...
                  }bits;
            }flags;

flags flg0; //, flg1;
//=============================
#define         flg_test         flg0.bits.B9           //for example
//------------
int main(void)
        {
                if(flg_test)
                        {
                                //do something..
                        }
        
                return 0;

        }
//============================

I believe this will generate the sbrs/sbrc instructions

--Royce.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]