From: sdattalo Date: Tue, 23 Jul 2002 14:15:12 +0000 (+0000) Subject: Interrupt context registers WSAVE and SSAVE were not getting allocated. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b74e476f6ba4e0e9e397c9aac11e92412fb0b71a;p=fw%2Fsdcc Interrupt context registers WSAVE and SSAVE were not getting allocated. Applied some more peephole and literal multiply patches from Freider Ferlemann git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2041 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/pic/device.c b/src/pic/device.c index 7c6d28a5..fe0ef872 100644 --- a/src/pic/device.c +++ b/src/pic/device.c @@ -102,7 +102,7 @@ void addMemRange(memRange *r, int type) do { for (i=r->start_address; i<= r->end_address; i++) { - if (i <= pic->maxRAMaddress) { + if ((i|alias) <= pic->maxRAMaddress) { finalMapping[i | alias].isValid = 1; finalMapping[i | alias].alias = r->alias; finalMapping[i | alias].bank = r->bank; @@ -112,6 +112,9 @@ void addMemRange(memRange *r, int type) } else { finalMapping[i | alias].isSFR = 0; } + } else { + fprintf(stderr, "WARNING: %s:%s memory at 0x%x is beyond max ram = 0x%x\n", + __FILE__,__FUNCTION__,(i|alias), pic->maxRAMaddress); } } @@ -403,6 +406,8 @@ int isSFR(int address) } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ int validAddress(int address, int reg_size) { int i; @@ -424,6 +429,8 @@ int validAddress(int address, int reg_size) return 1; } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ void mapRegister(regs *reg) { @@ -467,6 +474,8 @@ void mapRegister(regs *reg) } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ int assignRegister(regs *reg, int start_address) { int i; @@ -509,6 +518,8 @@ int assignRegister(regs *reg, int start_address) return -1; } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ void assignFixedRegisters(set *regset) { regs *reg; @@ -522,6 +533,8 @@ void assignFixedRegisters(set *regset) } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ void assignRelocatableRegisters(set *regset, int used) { diff --git a/src/pic/main.c b/src/pic/main.c index ea9dbad9..61485148 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -240,6 +240,7 @@ _pic14_genAssemblerPreamble (FILE * of) fprintf (of, "\tlist\tp=%s\n",&name[1]); fprintf (of, "\t__CONFIG 0x%x\n",getConfigWord(0x2007)); + fprintf (of, "\tradix dec"); fprintf (of, "\ninclude \"%s.inc\"\n",name); } diff --git a/src/pic/pcode.c b/src/pic/pcode.c index bbaede84..b7d0cd46 100644 --- a/src/pic/pcode.c +++ b/src/pic/pcode.c @@ -75,7 +75,7 @@ static pBlock *pb_dead_pcodes = NULL; /* Hardcoded flags to change the behavior of the PIC port */ static int peepOptimizing = 1; /* run the peephole optimizer if nonzero */ static int functionInlining = 1; /* inline functions if nonzero */ -int debug_verbose = 1; /* Set true to inundate .asm file */ +int debug_verbose = 0; /* Set true to inundate .asm file */ static int GpCodeSequenceNumber = 1; int GpcFlowSeq = 1; @@ -3671,7 +3671,7 @@ void LinkFlow(pBlock *pb) //pc->print(stderr,pc); if(!(pcol && isPCOLAB(pcol))) { - if((PCI(pc)->op != POC_RETLW) && (PCI(pc)->op != POC_RETURN) && (PCI(pc)->op != POC_CALL)) { + if((PCI(pc)->op != POC_RETLW) && (PCI(pc)->op != POC_RETURN) && (PCI(pc)->op != POC_CALL) && (PCI(pc)->op != POC_RETFIE) ) { pc->print(stderr,pc); fprintf(stderr, "ERROR: %s, branch instruction doesn't have label\n",__FUNCTION__); } diff --git a/src/pic/pcoderegs.c b/src/pic/pcoderegs.c index 7910f568..a7f72cc8 100644 --- a/src/pic/pcoderegs.c +++ b/src/pic/pcoderegs.c @@ -348,7 +348,7 @@ void RemoveUnusedRegisters(void) { /* First, get rid of registers that are used only one time */ - RemoveRegsFromSet(dynInternalRegs); + //RemoveRegsFromSet(dynInternalRegs); RemoveRegsFromSet(dynAllocRegs); RemoveRegsFromSet(dynStackRegs); /* diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index c9d8a5a6..fdafedf2 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -523,6 +523,8 @@ void initStack(int base_address, int size) addSet(&dynStackRegs,newReg(REG_STK, PO_GPR_TEMP,base_address++,NULL,1,0)); } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ regs * allocProcessorRegister(int rIdx, char * name, short po_type, int alias) { @@ -531,10 +533,13 @@ allocProcessorRegister(int rIdx, char * name, short po_type, int alias) return addSet(&dynProcessorRegs,newReg(REG_SFR, po_type, rIdx, name,1,alias)); } +/*-----------------------------------------------------------------* + *-----------------------------------------------------------------*/ + regs * allocInternalRegister(int rIdx, char * name, short po_type, int alias) { - regs * reg = newReg(REG_SFR, po_type, rIdx, name,1,alias); + regs * reg = newReg(REG_GPR, po_type, rIdx, name,1,alias); //fprintf(stderr,"allocInternalRegister %s addr =0x%x\n",name,rIdx); if(reg) { @@ -832,7 +837,7 @@ pic14_allocWithIdx (int idx) debugLog ("Dynamic Register not found\n"); - fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx); + //fprintf(stderr,"%s %d - requested register: 0x%x\n",__FUNCTION__,__LINE__,idx); werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "regWithIdx not found"); exit (1); @@ -1062,6 +1067,7 @@ void writeUsedRegs(FILE *of) { packBits(dynDirectBitRegs); + assignFixedRegisters(dynAllocRegs); assignFixedRegisters(dynStackRegs); assignFixedRegisters(dynDirectRegs); diff --git a/src/regression/mult1.c b/src/regression/mult1.c index 514e2647..d6b3f3e2 100644 --- a/src/regression/mult1.c +++ b/src/regression/mult1.c @@ -1,5 +1,8 @@ #define __16F873 #include "p16f873.h" + +#define TESTLIT 0x05 + unsigned char success=0; unsigned char failures=0; unsigned char dummy=0; @@ -41,6 +44,51 @@ void m2(unsigned char uc) failures++; } +void m3(unsigned char uc) +{ + volatile unsigned char vuc; + + // uchar = uchar * lit + // testing literal multiply with same source and destination + vuc = uc; + uc2 = 0; + uc1 = vuc; uc1 = uc1*1; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*2; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*3; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*4; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*5; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*6; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*7; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*8; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*9; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*10; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*11; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*12; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*13; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*14; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*15; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*16; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*17; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*18; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*19; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*20; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*21; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*22; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*23; if( uc1 != (uc2+=TESTLIT) ) failures++; + uc1 = vuc; uc1 = uc1*24; if( uc1 != (uc2+=TESTLIT) ) failures++; + + uc1 = vuc; uc1 = uc1*31; if( uc1 != ((31*TESTLIT) & 0xff) ) failures++; + uc1 = vuc; uc1 = uc1*32; if( uc1 != ((32*TESTLIT) & 0xff) ) failures++; + uc1 = vuc; uc1 = uc1*64; if( uc1 != ((64*TESTLIT) & 0xff) ) failures++; + uc1 = vuc; uc1 = uc1*128;if( uc1 != ((128*TESTLIT)& 0xff) ) failures++; + + // testing literal multiply with different source and destination + uc1 = vuc*1; if( uc1 != ((1*TESTLIT) & 0xff) ) failures++; + uc1 = vuc*2; if( uc1 != ((2*TESTLIT) & 0xff) ) failures++; + uc1 = vuc*4; if( uc1 != ((4*TESTLIT) & 0xff) ) failures++; +} + + void main(void) { dummy = 0; @@ -59,6 +107,7 @@ void main(void) ui3 = ui1*ui2; // uint = uint * unit + m3(TESTLIT); success = failures; done(); diff --git a/src/regression/string1.c b/src/regression/string1.c index e582fc5b..3f169c30 100644 --- a/src/regression/string1.c +++ b/src/regression/string1.c @@ -6,7 +6,7 @@ unsigned char dummy=0; //unsigned bit bit1; typedef unsigned char byte; -data at 0x06 unsigned char PORTB; + byte uchar0; const byte arr[] = { 1,2,8,9,0 };