Keil Logo Arm Logo

bitfields in bdata behaviour

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Nestor Lopez
Posted
16-Mar-2009 12:16 GMT
Toolset
C51
New! bitfields in bdata behaviour

Hello,

If a bdata variable is defined in the form:

struct foo
{
   unsigned char b1:1;
   unsigned char b2:1;
   unsigned char b3:1;
   unsigned char b4:1;
   unsigned char b5:1;
   unsigned char b6:1;
   unsigned char b7:1;
   unsigned char b8:1;
} bdata myflags;

Will the code:

if (myflags.b3)
   // do something

or the code:

myflags.b5 = 1;

generate the efficient 8051 code using jb, setb, etc?

I will do some testing myself, but in the meantime I'd like to know your ideas and advices.

I am porting some C code to Keil C51 and I am wondering if I can avoid the use of the bit and sbit keywords which are heavy extensions to C.

Thanks,
Nestor

Read-Only
Author
Andy Neil
Posted
16-Mar-2009 12:24 GMT
Toolset
C51
New! RE: bitfields in bdata behaviour

If the object is in bdata, then the most efficient way to access it is to use the bit-addressing features of the 8051 - not a 'C' bitfield.

Read-Only
Author
Nestor Lopez
Posted
16-Mar-2009 12:28 GMT
Toolset
C51
New! RE: bitfields in bdata behaviour

Thanks for your quick answer.

Nestor.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.