* src/pic16/gen.c (genPackBits): removed deprecated warning
[fw/sdcc] / src / pic16 / genutils.c
index d227e0abc74f0266e1e5054c72a42b586e337b09..4e077b4dce4eb2921315b3adbf599ac37b19b4be 100644 (file)
@@ -465,6 +465,36 @@ void gpsimDebug_StackDump(char *fname, int line, char *info)
   gpsimio2_lit('\n');
 }
 
+const char *gptr_fns[4][2] = {
+  { "_gptrget1", "_gptrput1" },
+  { "_gptrget2", "_gptrput2" },
+  { "_gptrget3", "_gptrput3" },
+  { "_gptrget4", "_gptrput4" } };
+
+extern set *externs;
+  
+/* generate a call to the generic pointer read/write functions */
+void pic16_callGenericPointerRW(int rw, int size)
+{
+  char buf[32];
+  symbol *sym;
+
+    if(size>4) {
+      werror(W_POSSBUG2, __FILE__, __LINE__);
+      abort();
+    }
+
+    strcpy(buf, port->fun_prefix);
+    strcat(buf, gptr_fns[size-1][rw]);
+    
+    pic16_emitpcode (POC_CALL, pic16_popGetWithString (buf));
+    
+    sym = newSymbol( buf, 0 );
+    sym->used++;
+    strcpy(sym->rname, buf);
+    checkAddSym(&externs, sym);
+}
+
 
 
 /* check all condition and return appropriate instruction, POC_CPFSGT or POC_CPFFSLT */
@@ -500,13 +530,15 @@ int pic16_genCmp_special(operand *left, operand *right, operand *result,
   int offs=0;
   symbol *tmplbl;
   unsigned long lit;
-  int op, cmp_op=0;
+  int op, cmp_op=0, cond_pre;
 
     FENTRY;
     
     if(!(pic16_options.opt_flags & OF_OPTIMIZE_CMP))return 0;
 
     size = max(AOP_SIZE(left), AOP_SIZE(right));
+
+    cond_pre = rIfx->condition; // must restore old value on return with 0!!!
     
     if(!isAOP_REGlike(left)) {
       operand *dummy;
@@ -554,5 +586,6 @@ int pic16_genCmp_special(operand *left, operand *right, operand *result,
 
     }          /* */
       
+  rIfx->condition = cond_pre;
   return 0;
 }