#2139 [PIC14] dummy reads from bitfields are broken

closed-fixed
5
2013-05-25
2013-03-03
No

(Copied original report from al_bin in "[Sdcc-user] Pic14 compiler bug" on 2013-03-01.)

I ported some working code to SDCC (PIC14, SVN ver. 8444).
And probably find bug in sdcc.
Striped down and preprocessed code looks OK

***************************test.c**********************************************
extern __at(0x0007) __sfr PORTC;

typedef struct
{
unsigned RC0 : 1;
unsigned RC1 : 1;
unsigned RC2 : 1;
unsigned RC3 : 1;
unsigned RC4 : 1;
unsigned RC5 : 1;
unsigned RC6 : 1;
unsigned RC7 : 1;
} __PORTCbits_t;

extern __at(0x0007) volatile __PORTCbits_t PORTCbits;
void
main(void)
{
((PORTCbits.RC3 = 1),(PORTCbits.RC3=0));
}
********************************************************************************

But compile:

sdcc --use-non-free --opt-code-size -mpic14 -p16f785 lcdp.c -o lcdp
popGet: (offset[0] > AOP_SIZE(op)[0]-1) && AOP_TYPE(op) != AOP_LIT)
WARNING: encountered NULL pcop--this is probably a compiler bug...

generated code:
***********************************************************************************
_main ;Function start
; 2 exit points
; .line 20; "lcdp.c" ((PORTCbits.RC3 = 1),(PORTCbits.RC3=0));
BANKSEL _PORTCbits
BSF _PORTCbits,3
BCF _PORTCbits,3
MOVLW (_PORTCbits + 0)
MOVWF FSR
BCF STATUS,7
BTFSC (_PORTCbits+1),0
BSF STATUS,7
MOVF INDF,W
ANDLW 0x08
BTFSS STATUS,2
RETURN
; exit point of _main

First lines looks OK, but testing unimplemented address 0x8 and conditional
return is wrong.

Albert

Discussion

  • Raphael Neider

    Raphael Neider - 2013-03-03

    Fixed exactly the described case in r8445.
    Similar cases are probably still broken.

     
  • Raphael Neider

    Raphael Neider - 2013-03-03
    • milestone: --> fixed
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks