#1209 BANKSEL missing

closed-fixed
nobody
5
2013-05-25
2006-10-04
hda
No

The PIC14 port sometimes does not produce BANKSEL
directive when it is needed. Here is an example:

-------
#include </usr/local/share/sdcc/include/pic/
pic16f877.h>

char i [60];
char j [60];

unsigned char o;

void main () {
i[0]=1;
j[0]=1;
}
-------

I have compiled this program with command

sdcc base.c -mpic14 -p16f877

The result assembler code for function main is:

-------

_main ;Function start
; 2 exit
points
;gen.c:9411:
size=0/1, offset=0, AOP_TYPE(res)=13
;; peep
5 - Removed redundant move
; .line
9; "base.c" i[0]=1;
000005 3001 movlw 0x1 MOVLW
0x01
; .line
10; "base.c" j[0]=1;
000006 1283 bcf 0x3, 0x5
BANKSEL _i
000007 1303 bcf 0x3, 0x6
000008 00a0 movwf 0x20 MOVWF
(_i + 0)
000009 00a0 movwf 0x20 MOVWF
(_j + 0)
00000a 0008 return
RETURN
-------

(from file base.lst).

Obviously, before the second MOVWF command it is
needed to insert "BANKSEL _j".

Discussion

  • hda

    hda - 2006-10-04

    Logged In: YES
    user_id=1611637

    I found a partial solution of this problem... it is in
    function BankSelect in file src/pic/pcode.c :

    -------
    if ((cur_bank == 'L')&&(bank == 'L')) { // If current
    bank and new bank are both allocated locally by the linker,
    then assume it is in same bank.
    return 'L'; // Local registers are presumed to
    be in same linker assigned bank
    -------

    I have inserted the
    -------
    insertBankSel(pci, reg->name);
    -------
    before return. Now the compiled programs work properly, but
    they have a lot of unneeded BANKSELs - every time when we
    access a variable other to previously accessed, ever if
    they both are in the same bank.

     
  • Maarten Brock

    Maarten Brock - 2006-10-05

    Logged In: YES
    user_id=888171

    Apart from the fact that this is the THIRD bug report
    about BANKSEL missing for pic14 targets... (I haven't
    checked if they overlap, have you?)

    This looks like a fine solution for the time being. I
    would rather have the compiler generate inefficient but
    working code than small but defective code.

    My recommendation is to implement and move the bug to
    feature requests to remind us there is need for
    improvement later. But I leave the decision to the pic
    port maintainers.

     
  • Raphael Neider

    Raphael Neider - 2006-10-15

    Logged In: YES
    user_id=1115835

    Fixed in SDCC r4409.
    Thanks for the report and a possible solution.

     
  • Raphael Neider

    Raphael Neider - 2006-10-15
    • milestone: 100454 --> fixed
    • status: open --> closed-fixed
     

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

Sign up for the SourceForge newsletter:





No, thanks