#define __REG32 volatile unsigend long

typedef struct
{
  __REG32 Bit0 :1;
  __REG32 Bit1 :1;
  ...etc...
  __REG32 Bit31 :1;
}__Bitfield;

#define ADDRESS <address of my register>

#define REG (*( __REG32 *)(ADDRESS))
#define REG_bit (*(__Bitfield *)&REG)

When I access the register using the bitfield I get the code like the following

LCD_bit.Backlight=1;            //??
     358:       e3a0320e        mov     r3, #-536870912 ; 0xe0000000
     35c:       e283390a        add     r3, r3, #163840 ; 0x28000
     360:       e5d32001        ldrb    r2, [r3, #1]
     364:       e3822004        orr     r2, r2, #4      ; 0x4
     368:       e5c32001        strb    r2, [r3, #1]


-- 
           Summary: compiler generates incorrect ARM instructions when using
                    long bitfields
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jason dot morgan at vpnsolutions dot uk dot com
GCC target triplet: arm-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28568

Reply via email to