* src/pic/pcode.c (InsertBankSel): suppress BANKSELs for one bank
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 15 Oct 2006 00:57:40 +0000 (00:57 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 15 Oct 2006 00:57:40 +0000 (00:57 +0000)
  devices,
  (BankSelect): emit BANKSEL before touching linker-placed regs,
  fixes #1570934

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4409 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/pic/pcode.c

index d5732d6245adcb11194a9bb31409634540b1ce02..d19b2c06e4b28e7950e15729656216556a3eaff1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-10-15 Raphael Neider <rneider AT web.de>
+
+       * src/pic/pcode.c (InsertBankSel): suppress BANKSELs for one bank
+         devices,
+         (BankSelect): emit BANKSEL before touching linker-placed regs,
+         fixes #1570934
+
 2006-10-10 Raphael Neider <rneider AT web.de>
 
        * src/SDCCmain.c (optionsTable): accept --stack-size for PICs,
index d29b62e42b5486f36b3ed652388481308783a66b..1951de072bf6f28e090b024d7add965c29bda5b3 100644 (file)
@@ -4556,7 +4556,12 @@ static void insertBankSel(pCodeInstruction  *pci, const char *name)
 {
        pCode *new_pc;
        
-       pCodeOp *pcop = popCopyReg(PCOR(pci->pcop));
+       pCodeOp *pcop;
+
+       // This is a NOP for single-banked devices.
+       if (pic14_getMaxRam() < 0x80) return;
+       
+       pcop = popCopyReg(PCOR(pci->pcop));
        pcop->type = PO_GPR_REGISTER; // Sometimes the type is set to legacy 8051 - so override it
        if (pcop->name == 0)
                pcop->name = strdup(name);
@@ -4609,11 +4614,7 @@ static int BankSelect(pCodeInstruction *pci, int cur_bank, regs *reg)
        } else {
                bank = 'L'; // Unfixed local registers are allocated by the linker therefore its bank is unknown
        }
-       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
-       } else if ((bank == 'L')&&(cur_bank != 'L')) { // Reg is now local and linker to assign bank
-               insertBankSel(pci, reg->name); // Let linker choose the bank selection
-       } else if (bank == 'E') { // Reg is now extern and linker to assign bank
+       if (bank == 'E' || bank == 'L') { // Reg is now extern and linker to assign bank
                insertBankSel(pci, reg->name); // Let linker choose the bank selection
        } else if ((cur_bank == -1)||(cur_bank == 'L')||(cur_bank == 'E')) { // Current bank unknown and new register bank is known then can set bank bits
                insertBankSwitch(pci, bank&1, PIC_RP0_BIT);