]> git.gag.com Git - fw/sdcc/commitdiff
* src/pic16/gen.c (genPackBits): added operand right in function
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 1 Sep 2004 10:16:29 +0000 (10:16 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 1 Sep 2004 10:16:29 +0000 (10:16 +0000)
parameters, load result directly if p_type is POINTER (that is
called by genNearPointerSet)
* (genUnPackBits): added operand left in function parameters,
* (genNearPointerGet, genNearPointerSet): prevent the loading of
FSR0 if accessing bitfields,

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

ChangeLog
src/pic16/NOTES
src/pic16/gen.c
src/pic16/main.c
src/pic16/main.h

index 8aa4ffe0a4a4a09c13166cfb58ecaab2bca23954..1c547f984319897b84e5d09b69da34ce154931f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-09-01 Vangelis Rokas <vrokas AT otenet.gr>
+
+       * src/pic16/gen.c (genPackBits): added operand right in function
+       parameters, load result directly if p_type is POINTER (that is
+       called by genNearPointerSet)
+       * (genUnPackBits): added operand left in function parameters,
+       * (genNearPointerGet, genNearPointerSet): prevent the loading of
+       FSR0 if accessing bitfields,
+
 2004-08-31 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * device/include/stdio.h: added NULL, size_t, typedef pfn_outputchar,
index 4d38a12d0abc9e6ddee7ab931484dcfb7b207873..67cb9eacf8da03a24e7b0dbbca27668ac36a9ea9 100644 (file)
@@ -18,6 +18,27 @@ Scott Dattalo        <scott AT dattalo.com>
 
 ======================================================================
 ======================================================================
+2004-Aug-30 Vangelis Rokas
+1. A few months ago Hans Dorn had the idea to support general pointer
+for accessing all code, eeprom data and data ram memory. These pointers
+would have 3 bytes of size (24-bits), of which only the 21 lower bits
+would be useful. The rest of them could be used to indicate the pointer
+type. I.e.
+0x4xxxxxxx would mean code pointer
+0x8xxxxxxx would mean eeprom pointer
+0xcxxxxxxx would mean data ram pointer
+
+The implementatio of such pointers needs a lot of work and general
+reform of pointer access, data initializing functions and the writing
+of support functions for decoding their type.
+
+The implementation of such pointers along with the implementation of
+a more SDCC like stack access system will allow the writing of variable
+arguments functions like printf etc... Also one set of functions will be
+able to handle all data types without having to worry about where they
+are placed.
+
+
 2004-May-23 Vangelis Rokas
 
 1. The improvement of the port has been stalled a bit. But, struct/union
index 6d6e8bd669bb16b4cb2dfc2b47d77e2bae6c0b32..f39c93df6606ba878122b104b87ce075385b79db 100644 (file)
@@ -9183,7 +9183,7 @@ release:
 /*-----------------------------------------------------------------*/
 /* genUnpackBits - generates code for unpacking bits               */
 /*-----------------------------------------------------------------*/
-static void genUnpackBits (operand *result, char *rname, int ptype)
+static void genUnpackBits (operand *result, operand *left, char *rname, int ptype)
 {    
     int shCnt ;
     int rlen = 0 ;
@@ -9421,7 +9421,8 @@ static void genNearPointerGet (operand *left,
                        && ((AOP(left)->aopu.pcop->type == PO_IMMEDIATE)
                                || (AOP(left)->aopu.pcop->type == PO_DIR))) // patch 10
                {
-                       pic16_loadFSR0( left );  // patch 10
+                       if(!IS_BITFIELD(retype))
+                               pic16_loadFSR0( left );  // patch 10
                } else {
                        // set up FSR0 with address from left
                        pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),0), pic16_popCopyReg(&pic16_pc_fsr0l))); // patch 10
@@ -9435,7 +9436,7 @@ static void genNearPointerGet (operand *left,
     
       /* if bitfield then unpack the bits */
     if (IS_BITFIELD(retype)) 
-       genUnpackBits (result, NULL, POINTER);
+       genUnpackBits (result, left, NULL, POINTER);
     else {
        /* we have can just get the values */
       int size = AOP_SIZE(result);
@@ -9549,7 +9550,7 @@ static void genPagedPointerGet (operand *left,
 
     /* if bitfield then unpack the bits */
     if (IS_BITFIELD(retype)) 
-       genUnpackBits (result,rname,PPOINTER);
+       genUnpackBits (result,left,rname,PPOINTER);
     else {
        /* we have can just get the values */
        int size = AOP_SIZE(result);
@@ -9627,7 +9628,7 @@ static void genFarPointerGet (operand *left,
 
     /* if bit then unpack */
     if (IS_BITFIELD(retype)) 
-        genUnpackBits(result,"dptr",FPOINTER);
+        genUnpackBits(result,left,"dptr",FPOINTER);
     else {
         size = AOP_SIZE(result);
         offset = 0 ;
@@ -9677,7 +9678,7 @@ static void genCodePointerGet (operand *left,
 
     /* if bit then unpack */
     if (IS_BITFIELD(retype)) 
-        genUnpackBits(result,"dptr",CPOINTER);
+        genUnpackBits(result,left,"dptr",CPOINTER);
     else {
         size = AOP_SIZE(result);
         offset = 0 ;
@@ -9750,7 +9751,7 @@ static void genGenPointerGet (operand *left,
 
   /* if bit then unpack */
        if (IS_BITFIELD(retype)) 
-               genUnpackBits(result,"BAD",GPOINTER);
+               genUnpackBits(result,left,"BAD",GPOINTER);
 
        release:
        pic16_freeAsmop(left,NULL,ic,TRUE);
@@ -9929,7 +9930,7 @@ static void genPointerGet (iCode *ic)
 /*-----------------------------------------------------------------*/
 /* genPackBits - generates code for packed bit storage             */
 /*-----------------------------------------------------------------*/
-static void genPackBits (sym_link    *etype ,
+static void genPackBits (sym_link    *etype , operand *result,
                          operand *right ,
                          char *rname, int p_type)
 {
@@ -9952,12 +9953,24 @@ static void genPackBits (sym_link    *etype ,
 
                        lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
 //                     pic16_emitpcode(POC_MOVFW, pic16_popCopyReg(&pic16_pc_indf0));
-                       if(lit) {
-                               pic16_emitpcode(POC_BSF,
-                                       pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+                       if((p_type == POINTER) && (result)) {
+                               /* workaround to reduce the extra lfsr instruction */
+                               if(lit) {
+                                       pic16_emitpcode(POC_BSF,
+                                               pic16_popCopyGPR2Bit(pic16_popGet(AOP(result), 0), bstr));
+                               } else {
+                                       pic16_emitpcode(POC_BCF,
+                                               pic16_popCopyGPR2Bit(pic16_popGet(AOP(result), 0), bstr));
+                               }
                        } else {
-                               pic16_emitpcode(POC_BCF,
-                                       pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+
+                               if(lit) {
+                                       pic16_emitpcode(POC_BSF,
+                                               pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+                               } else {
+                                       pic16_emitpcode(POC_BCF,
+                                               pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
+                               }
                        }
        
                  return;
@@ -10192,6 +10205,7 @@ static void genNearPointerSet (operand *right,
                        && ((AOP(result)->aopu.pcop->type == PO_IMMEDIATE)
                                || (AOP(result)->aopu.pcop->type == PO_DIR))) // patch 10
                {
+                 if(!IS_BITFIELD(resetype))
                        pic16_loadFSR0( result );  // patch 10
                } else {
                        // set up FSR0 with address of result
@@ -10207,7 +10221,7 @@ static void genNearPointerSet (operand *right,
 
        /* if bitfield then unpack the bits */
        if (IS_BITFIELD(resetype)) {
-               genPackBits (resetype, right, NULL, POINTER);
+               genPackBits (resetype, result, right, NULL, POINTER);
        } else {
                /* we have can just get the values */
          int size = AOP_SIZE(right);
@@ -10313,7 +10327,7 @@ static void genPagedPointerSet (operand *right,
 
     /* if bitfield then unpack the bits */
     if (IS_BITFIELD(retype)) 
-       genPackBits (retype,right,rname,PPOINTER);
+       genPackBits (retype,result,right,rname,PPOINTER);
     else {
        /* we have can just get the values */
        int size = AOP_SIZE(right);
@@ -10391,7 +10405,7 @@ static void genFarPointerSet (operand *right,
 
     /* if bit then unpack */
     if (IS_BITFIELD(retype)) 
-        genPackBits(retype,right,"dptr",FPOINTER);
+        genPackBits(retype,result,right,"dptr",FPOINTER);
     else {
         size = AOP_SIZE(right);
         offset = 0 ;
@@ -10498,7 +10512,7 @@ static void genGenPointerSet (operand *right,
 
        /* if bit then unpack */
        if (IS_BITFIELD(retype)) 
-               genPackBits(retype,right,"dptr",GPOINTER);
+               genPackBits(retype,result,right,"dptr",GPOINTER);
        else {
                size = AOP_SIZE(right);
                offset = 0 ;
@@ -10837,12 +10851,14 @@ static void genAssign (iCode *ic)
   if(AOP_TYPE(right) != AOP_LIT
        && IN_CODESPACE(SPEC_OCLS(OP_SYMBOL(right)->etype))) {
        DEBUGpic16_emitcode(";   ", "%s:%d symbol in code space, take special care\n", __FUNCTION__, __LINE__);
+       fprintf(stderr, "%s:%d symbol %s = [ %s ] is in code space\n", __FILE__, __LINE__, OP_SYMBOL(result)->name, OP_SYMBOL(right)->name);
 
        // set up table pointer
        if( (AOP_TYPE(right) == AOP_PCODE)
                && ((AOP(right)->aopu.pcop->type == PO_IMMEDIATE)
                || (AOP(right)->aopu.pcop->type == PO_DIR)))
        {
+               fprintf(stderr, "%s:%d inside block 1\n", __FILE__, __LINE__);
                pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),0));
                pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptrl));
                pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),1));
@@ -10850,6 +10866,7 @@ static void genAssign (iCode *ic)
                pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),2));
                pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptru));
        } else {
+               fprintf(stderr, "%s:%d inside block 2\n", __FILE__, __LINE__);
                pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(right),0),
                                pic16_popCopyReg(&pic16_pc_tblptrl)));
                pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(right),1),
index 727bee62c2eabb59b631b3c3c191c4b0d67a066f..b739f3426d7829624a394989d91e04f782ba5f4b 100644 (file)
@@ -286,6 +286,8 @@ _process_pragma(const char *sz)
 #define NO_DEFLIBS     "--nodefaultlibs"
 #define MPLAB_COMPAT   "--mplab-comp"
 
+#define NL_OPT         "--nl="
+
 char *alt_asm=NULL;
 char *alt_link=NULL;
 
@@ -296,6 +298,7 @@ extern int pic16_pcode_verbose;
 
 int pic16_fstack=0;
 int pic16_enable_peeps=0;
+int pic16_nl=0;                        /* 0 for LF, 1 for CRLF */
 
 OPTION pic16_optionsTable[]= {
        { 0,    NO_DEFLIBS,             &pic16_options.nodefaultlibs,   "do not link default libraries when linking"},
@@ -304,7 +307,7 @@ OPTION pic16_optionsTable[]= {
        { 0,    "--pomit-config-words", &pic16_options.omit_configw,    "omit the generation of configuration words"},
        { 0,    "--pomit-ivt",          &pic16_options.omit_ivt,        "omit the generation of the Interrupt Vector Table"},
        { 0,    "--pleave-reset-vector",&pic16_options.leave_reset,     "when omitting IVT leave RESET vector"},
-       { 0,    STACK_MODEL,    NULL,   "use stack model 'small' (default) or 'large'"},
+       { 0,    STACK_MODEL,            NULL,                           "use stack model 'small' (default) or 'large'"},
 
        { 0,    "--debug-xtra",         &pic16_debug_verbose,   "show more debug info in assembly output"},
        { 0,    "--debug-ralloc",       &pic16_ralloc_debug,    "dump register allocator debug file *.d"},
@@ -320,6 +323,7 @@ OPTION pic16_optionsTable[]= {
        { 0,    "--calltree",           &pic16_options.dumpcalltree,    "dump call tree in .calltree file"},
        { 0,    MPLAB_COMPAT,           &pic16_mplab_comp,      "enable compatibility mode for MPLAB utilities (MPASM/MPLINK)"},
        { 0,    "--fstack",             &pic16_fstack,          "enable stack optimizations"},
+       { 0,    NL_OPT,         NULL,                           "new line, \"lf\" or \"crlf\""},
        { 0,    NULL,           NULL,   NULL}
        };
 
@@ -350,8 +354,8 @@ _pic16_parseOptions (int *pargc, char **argv, int *i)
 
        if(ISOPT(STACK_MODEL)) {
                stkmodel = getStringArg(STACK_MODEL, argv, i, *pargc);
-               if(STRCASECMP(stkmodel, "small"))pic16_options.stack_model = 0;
-               else if(STRCASECMP(stkmodel, "large"))pic16_options.stack_model = 1;
+               if(!STRCASECMP(stkmodel, "small"))pic16_options.stack_model = 0;
+               else if(!STRCASECMP(stkmodel, "large"))pic16_options.stack_model = 1;
                else {
                        fprintf(stderr, "Unknown stack model: %s", stkmodel);
                        exit(-1);
@@ -383,7 +387,20 @@ _pic16_parseOptions (int *pargc, char **argv, int *i)
                pic16_options.ivt_loc = getIntArg(IVT_LOC, argv, i, *pargc);
                return TRUE;
        }
-
+       
+       if(ISOPT(NL_OPT)) {
+          char *tmp;
+            
+            tmp = Safe_strdup( getStringArg(NL_OPT, argv, i, *pargc) );
+            if(!STRCASECMP(tmp, "lf"))pic16_nl = 0;
+            else if(!STRCASECMP(tmp, "crlf"))pic16_nl = 1;
+            else {
+                  fprintf(stderr, "invalid termination character id\n");
+                  exit(-1);
+            }
+            return TRUE;
+        }
+        
   return FALSE;
 }
 
index 387c61c045945f2363525a9948635d296aa69bce..7e392925f4144c374f7ba94689e059455c115649 100644 (file)
@@ -34,5 +34,6 @@ extern set *sectSyms;
 
 extern int pic16_mplab_comp;
 extern int pic16_fstack;
+extern int pic16_nl;
 
 #endif