* src/SDCCmain.c (linkEdit): modifications only for pic16 port,
[fw/sdcc] / src / pic16 / pcode.h
index 2b57ef5d2f36fd181ee4541a5157847df5961d90..950251b1a19bc3fcdf8e955ffbeb1c44063d63f3 100644 (file)
@@ -157,6 +157,9 @@ typedef enum
   PO_SFR_REGISTER,   // A special function register (e.g. PORTA)
   PO_PCL,            // Program counter Low register
   PO_PCLATH,         // Program counter Latch high register
+  PO_PCLATU,         // Program counter Latch upper register
+  PO_PRODL,          // Product Register Low
+  PO_PRODH,          // Product Register High
   PO_LITERAL,        // A constant
   PO_REL_ADDR,       // A relative address
   PO_IMMEDIATE,      //  (8051 legacy)
@@ -264,11 +267,20 @@ typedef enum
   POC_SUBFWB_D1,
   POC_SWAPF,
   POC_SWAPFW,
-//  POC_TRIS , // To be removed
+  POC_TBLRD,
+  POC_TBLRD_POSTINC,
+  POC_TBLRD_POSTDEC,
+  POC_TBLRD_PREINC,
+  POC_TBLWT,
+  POC_TBLWT_POSTINC,
+  POC_TBLWT_POSTDEC,
+  POC_TBLWT_PREINC,
   POC_TSTFSZ,
   POC_XORLW,
   POC_XORWF,
-  POC_XORFW
+  POC_XORFW,
+
+  POC_BANKSEL
 } PIC_OPCODE;
 
 
@@ -364,14 +376,14 @@ typedef struct pCodeOpLit2
 {
   pCodeOp pcop;
   int lit;
-  int lit2;
+  pCodeOp *arg2;
 } pCodeOpLit2;
 
 
 typedef struct pCodeOpImmd
 {
   pCodeOp pcop;
-  int offset;           /* low,med, or high byte of immediat value */
+  int offset;           /* low,high or upper byte of immediate value */
   int index;            /* add this to the immediate value */
   unsigned _const:1;    /* is in code space    */
 
@@ -429,6 +441,8 @@ typedef struct pCodeOpWild
   pCodeOp *matched;       /* When a wild matches, we'll store a pointer to the
                           * opcode we matched */
 
+  pCodeOp *pcop2;        /* second operand if exists */
+
 } pCodeOpWild;
 
 
@@ -498,17 +512,6 @@ typedef struct pCodeCSource
     pCodeAsmDir
 **************************************************/
 
-typedef struct pCodeAsmDir
-{
-  pCode pc;
-  
-  char *directive;
-  char *arg;
-
-  pBranch *label;
-} pCodeAsmDir;
-
-
 /*************************************************
     pCodeFlow
 
@@ -620,6 +623,20 @@ typedef struct pCodeInstruction
 } pCodeInstruction;
 
 
+
+/*************************************************
+    pCodeAsmDir
+**************************************************/
+
+typedef struct pCodeAsmDir
+{
+  pCodeInstruction pci;
+  
+  char *directive;
+  char *arg;
+} pCodeAsmDir;
+
+
 /*************************************************
     pCodeLabel
 **************************************************/
@@ -631,6 +648,7 @@ typedef struct pCodeLabel
 
   char *label;
   int key;
+  int force;           /* label cannot be optimized out */
 
 } pCodeLabel;
 
@@ -655,6 +673,10 @@ typedef struct pCodeFunction
 
   int  ncalled;    /* Number of times function is called */
 
+  int absblock;    /* hack to emulate a block pCodes in absolute position
+                      but not inside a function */
+  int stackusage;  /* stack positions used in function */
+  
 } pCodeFunction;
 
 
@@ -842,7 +864,7 @@ typedef struct peepCommand {
 #define PCOR2(x)  ((pCodeOpReg2 *)(x))
 #define PCORB(x)  ((pCodeOpRegBit *)(x))
 #define PCOW(x)   ((pCodeOpWild *)(x))
-
+#define PCOW2(x)  (PCOW(PCOW(x)->pcop2))
 #define PBR(x)    ((pBranch *)(x))
 
 #define PCWB(x)   ((pCodeWildBlock *)(x))
@@ -866,24 +888,7 @@ typedef struct peepCommand {
 #define isCALL(x)       ((isPCI(x)) && (PCI(x)->op == POC_CALL))
 #define isSTATUS_REG(r) ((r)->pc_type == PO_STATUS)
 #define isBSR_REG(r)    ((r)->pc_type == PO_BSR)
-
-#if 0
-/* these are deprecated since when creating relocatable code, the register
-   address is not known (except of course of the SFRs and the Fixed registers)
-*/
-
-
-#define isACCESS_LOW(r) ((pic16_finalMapping[REG_ADDR(r)].bank == \
-                          PIC_BANK_FIRST) && (REG_ADDR(r) < 0x80))
-#define isACCESS_HI(r)  (pic16_finalMapping[REG_ADDR(r)].bank == PIC_BANK_LAST)
-#define isACCESS_BANK(r)       (isACCESS_LOW(r) || isACCESS_HI(r))
-
-#endif
-
-//#define isACCESS_BANK(r)     (REG_ADDR(r)!= 0)
 #define isACCESS_BANK(r)       (r->accessBank)
-// && pic16_finalMapping[REG_ADDR(r)].isSFR)
-//                             || (pic16_finalMapping[(r)->rIdx].reg && pic16_finalMapping[(r)->rIdx].reg->isFixed))
 
 
 
@@ -898,6 +903,7 @@ pCode *pic16_newpCodeCharP(char *cP);              // Create a new pCode given a
 pCode *pic16_newpCodeInlineP(char *cP);            // Create a new pCode given a char *
 pCode *pic16_newpCodeFunction(char *g, char *f);   // Create a new function
 pCode *pic16_newpCodeLabel(char *name,int key);    // Create a new label given a key
+pCode *pic16_newpCodeLabelFORCE(char *name, int key); // Same as newpCodeLabel but label cannot be optimized out
 pCode *pic16_newpCodeCSource(int ln, char *f, char *l); // Create a new symbol line 
 pBlock *pic16_newpCodeChain(memmap *cm,char c, pCode *pc); // Create a new pBlock
 void pic16_printpBlock(FILE *of, pBlock *pb);      // Write a pBlock to a file
@@ -910,12 +916,19 @@ void pic16_AssignRegBanks(void);
 void pic16_printCallTree(FILE *of);
 void pCodePeepInit(void);
 void pic16_pBlockConvert2ISR(pBlock *pb);
+void pic16_pBlockConvert2Absolute(pBlock *pb);
+void pic16_initDB(void);
+void pic16_emitDB(char c, char ptype, void *p);                  // Add DB directives to a pBlock
+void pic16_emitDS(char *s, char ptype, void *p);
+void pic16_flushDB(char ptype, void *p);                         // Add pending DB data to a pBlock
+
+pCode *pic16_newpCodeAsmDir(char *asdir, char *argfmt, ...); 
 
 pCodeOp *pic16_newpCodeOpLabel(char *name, int key);
 pCodeOp *pic16_newpCodeOpImmd(char *name, int offset, int index, int code_space);
 pCodeOp *pic16_newpCodeOpLit(int lit);
-pCodeOp *pic16_newpCodeOpLit2(int lit, int lit2);
-pCodeOp *pic16_newpCodeOpBit(char *name, int bit,int inBitSpace);
+pCodeOp *pic16_newpCodeOpLit2(int lit, pCodeOp *arg2);
+pCodeOp *pic16_newpCodeOpBit(char *name, int bit,int inBitSpace, PIC_OPTYPE subt);
 pCodeOp *pic16_newpCodeOpRegFromStr(char *name);
 pCodeOp *pic16_newpCodeOp(char *name, PIC_OPTYPE p);
 pCodeOp *pic16_pCodeOpCopy(pCodeOp *pcop);
@@ -927,6 +940,8 @@ struct regs * pic16_getRegFromInstruction(pCode *pc);
 struct regs * pic16_getRegFromInstruction2(pCode *pc);
 
 extern void pic16_pcode_test(void);
+extern int pic16_debug_verbose;
+extern int pic16_pcode_verbose;
 
 /*-----------------------------------------------------------------*
  * pCode objects.
@@ -934,19 +949,47 @@ extern void pic16_pcode_test(void);
 
 extern pCodeOpReg pic16_pc_status;
 extern pCodeOpReg pic16_pc_intcon;
-extern pCodeOpReg pic16_pc_indf0;
-extern pCodeOpReg pic16_pc_fsr0;
 extern pCodeOpReg pic16_pc_pcl;
 extern pCodeOpReg pic16_pc_pclath;
+extern pCodeOpReg pic16_pc_pclatu; // patch 14
 extern pCodeOpReg pic16_pc_wreg;
+extern pCodeOpReg pic16_pc_tosl; // patch 14
+extern pCodeOpReg pic16_pc_tosh; // patch 14
+extern pCodeOpReg pic16_pc_tosu; // patch 14
+extern pCodeOpReg pic16_pc_tblptrl; // patch 15
+extern pCodeOpReg pic16_pc_tblptrh; //
+extern pCodeOpReg pic16_pc_tblptru; //
+extern pCodeOpReg pic16_pc_tablat;  // patch 15
+extern pCodeOpReg pic16_pc_bsr;
+extern pCodeOpReg pic16_pc_fsr0;
+extern pCodeOpReg pic16_pc_fsr0l;
+extern pCodeOpReg pic16_pc_fsr0h;
 extern pCodeOpReg pic16_pc_fsr1l;
 extern pCodeOpReg pic16_pc_fsr1h;
 extern pCodeOpReg pic16_pc_fsr2l;
 extern pCodeOpReg pic16_pc_fsr2h;
+extern pCodeOpReg pic16_pc_indf0;
+extern pCodeOpReg pic16_pc_postinc0;
+extern pCodeOpReg pic16_pc_postdec0;
+extern pCodeOpReg pic16_pc_preinc0;
+extern pCodeOpReg pic16_pc_plusw0;
+extern pCodeOpReg pic16_pc_indf1;
 extern pCodeOpReg pic16_pc_postinc1;
 extern pCodeOpReg pic16_pc_postdec1;
+extern pCodeOpReg pic16_pc_preinc1;
+extern pCodeOpReg pic16_pc_plusw1;
+extern pCodeOpReg pic16_pc_indf2;
+extern pCodeOpReg pic16_pc_postinc2;
+extern pCodeOpReg pic16_pc_postdec2;
 extern pCodeOpReg pic16_pc_preinc2;
 extern pCodeOpReg pic16_pc_plusw2;
+extern pCodeOpReg pic16_pc_prodl;
+extern pCodeOpReg pic16_pc_prodh;
+
+extern pCodeOpReg pic16_pc_eecon1;
+extern pCodeOpReg pic16_pc_eecon2;
+extern pCodeOpReg pic16_pc_eedata;
+extern pCodeOpReg pic16_pc_eeadr;
 
 extern pCodeOpReg pic16_pc_kzero;
 extern pCodeOpReg pic16_pc_wsave;     /* wsave and ssave are used to save W and the Status */