On pic14, the following 'simple' structure assignment ...
#define NO_BIT_DEFINES
#include <pic16f1459.h>
void main(void)
{
OSCCONbits.SCS = 0b01;
}
... results in unpectedted instructions ...
MOVLW (_OSCCONbits + 0)
ANDLW 0xfc
IORLW 0x01
BANKSEL _OSCCONbits
MOVWF (_OSCCONbits + 0)
... where it should produce a similar sequence to the pic16 version ...
BANKSEL _OSCCONbits
MOVF _OSCCONbits, W
ANDLW 0xfc
IORLW 0x01
MOVWF _OSCCONbits
... naturally the resulting code does not work as expected.
Best,
Herbert
I narrowed the issue down to a change between 3.6.0 and 3.7.0 where a condition was modified with dramatic results ...
https://sourceforge.net/p/sdcc/code/9836/tree//trunk/sdcc/src/pic14/gen.c?diff=513f4d42271846342871488b:9835
Here the last hunk (and especially the || part with PO_IMMEDIATE seems to be the problem, because the following patch seems to 'fix' the issue: http://vserver.13thfloor.at/Stuff/SDCC/sdcc-pic14-immediate.diff
Note that IMHO all pic14 MCUs are affected and I'm really surprised that nobody noticed this problem which has been there for quite some while.
Hope this helps,
Herbert
Could you check if the bug is also present in the pic14 branch?
Philipp
https://sourceforge.net/p/sdcc/code/HEAD/tree/branches/pic14/sdcc/src/pic14/gen.c certainly shows the || PO_IMMEDIATE in line 7995.