]> git.gag.com Git - fw/sdcc/commitdiff
Interrupt context registers WSAVE and SSAVE were not getting allocated.
authorsdattalo <sdattalo@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 23 Jul 2002 14:15:12 +0000 (14:15 +0000)
committersdattalo <sdattalo@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 23 Jul 2002 14:15:12 +0000 (14:15 +0000)
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

src/pic/device.c
src/pic/main.c
src/pic/pcode.c
src/pic/pcoderegs.c
src/pic/ralloc.c
src/regression/mult1.c
src/regression/string1.c

index 7c6d28a5339c857f7b95eab3ddd5efa9df8e14ef..fe0ef87236c80c93544439c81146c94fe8b5e98c 100644 (file)
@@ -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)
 {
 
index ea9dbad90cedb0ad2e10970337466acc3b9f4420..61485148ae29afc66af81a7498eb613555a4022e 100644 (file)
@@ -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);
 }
 
index bbaede8459eb23808e50f27fa9cf5d71d2ac9bf9..b7d0cd461a9205f3df4c777bd6f2fb65f7eca80a 100644 (file)
@@ -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__);
        }
index 7910f568d6fcf50091149d25effbadd39b0b76f2..a7f72cc83f48106cd3c1d8ee98ad6e46edf505fe 100644 (file)
@@ -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);
   /*
index c9d8a5a665054ac2d0da93cd3ccee52a5bea24c1..fdafedf227e2648245808e4ccb05600682320644 100644 (file)
@@ -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);
index 514e264700a7c8ac6a3ffee52b1e8dfbc2b6e435..d6b3f3e2a5a0f00f3c668304761174d8a24a5a4f 100644 (file)
@@ -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();
index e582fc5bb385e5c1421853c5adb5224873896780..3f169c300aedbd3d2529a54ad829323e44e6ffd3 100644 (file)
@@ -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 };