+int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd);
+int pCodePeepMatchRule(pCode *pc);
+
+
+pCodeInstruction pciADDWF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_ADDWF,
+ "ADDWF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z) // outCond
+};
+
+pCodeInstruction pciADDFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_ADDWF,
+ "ADDWF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciADDLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_ADDLW,
+ "ADDLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ (PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+pCodeInstruction pciANDLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_ANDLW,
+ "ANDLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciANDWF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_ANDWF,
+ "ANDWF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z) // outCond
+};
+
+pCodeInstruction pciANDFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_ANDWF,
+ "ANDWF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciBCF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_BCF,
+ "BCF",
+ NULL, // operand
+ 2, // num ops
+ 0,1, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_EXAMINE_PCOP // outCond
+};
+
+pCodeInstruction pciBSF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_BSF,
+ "BSF",
+ NULL, // operand
+ 2, // num ops
+ 0,1, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_EXAMINE_PCOP // outCond
+};
+
+pCodeInstruction pciBTFSC = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeSKIP,
+ genericDestruct,
+ genericPrint},
+ POC_BTFSC,
+ "BTFSC",
+ NULL, // operand
+ 2, // num ops
+ 0,1, // dest, bit instruction
+ PCC_EXAMINE_PCOP, // inCond
+ PCC_NONE // outCond
+};
+
+pCodeInstruction pciBTFSS = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeSKIP,
+ genericDestruct,
+ genericPrint},
+ POC_BTFSS,
+ "BTFSS",
+ NULL, // operand
+ 2, // num ops
+ 0,1, // dest, bit instruction
+ PCC_EXAMINE_PCOP, // inCond
+ PCC_NONE // outCond
+};
+
+pCodeInstruction pciCALL = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_CALL,
+ "CALL",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_NONE // outCond
+};
+
+pCodeInstruction pciCOMF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_COMF,
+ "COMF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_REGISTER // outCond
+};
+
+pCodeInstruction pciCOMFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_COMFW,
+ "COMF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciCLRF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_CLRF,
+ "CLRF",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_REGISTER // outCond
+};
+
+pCodeInstruction pciCLRW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_CLRW,
+ "CLRW",
+ NULL, // operand
+ 0, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciDECF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_DECF,
+ "DECF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_REGISTER // outCond
+};
+
+pCodeInstruction pciDECFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_DECFW,
+ "DECF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciDECFSZ = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeSKIP,
+ genericDestruct,
+ genericPrint},
+ POC_DECFSZ,
+ "DECFSZ",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_REGISTER // outCond
+};
+
+pCodeInstruction pciDECFSZW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeSKIP,
+ genericDestruct,
+ genericPrint},
+ POC_DECFSZW,
+ "DECFSZ",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciGOTO = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeGOTO,
+ genericDestruct,
+ genericPrint},
+ POC_GOTO,
+ "GOTO",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_NONE // outCond
+};
+
+
+pCodeInstruction pciINCF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_INCF,
+ "INCF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_REGISTER // outCond
+};
+
+pCodeInstruction pciINCFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_INCFW,
+ "INCF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciINCFSZ = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeSKIP,
+ genericDestruct,
+ genericPrint},
+ POC_INCFSZ,
+ "INCFSZ",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_REGISTER // outCond
+};
+
+pCodeInstruction pciINCFSZW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeSKIP,
+ genericDestruct,
+ genericPrint},
+ POC_INCFSZW,
+ "INCFSZ",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciIORWF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_IORWF,
+ "IORWF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z) // outCond
+};
+
+pCodeInstruction pciIORFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_IORWF,
+ "IORWF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciIORLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_IORLW,
+ "IORLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciMOVF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_MOVF,
+ "MOVF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_Z // outCond
+};
+
+pCodeInstruction pciMOVFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_MOVFW,
+ "MOVF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciMOVWF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_MOVWF,
+ "MOVWF",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ 0 // outCond
+};
+
+pCodeInstruction pciMOVLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_MOVLW,
+ "MOVLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciNEGF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_NEGF,
+ "NEGF",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_REGISTER, // inCond
+ PCC_NONE // outCond
+};
+
+
+pCodeInstruction pciRETLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeRETURN,
+ genericDestruct,
+ genericPrint},
+ POC_RETLW,
+ "RETLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_W // outCond
+};
+
+pCodeInstruction pciRETURN = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ AnalyzeRETURN,
+ genericDestruct,
+ genericPrint},
+ POC_RETURN,
+ "RETURN",
+ NULL, // operand
+ 0, // num ops
+ 0,0, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_W // outCond
+};
+
+
+pCodeInstruction pciRLF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_RLF,
+ "RLF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_C | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+pCodeInstruction pciRLFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_RLFW,
+ "RLF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_C | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+pCodeInstruction pciRRF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_RRF,
+ "RRF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_C | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+pCodeInstruction pciRRFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_RRFW,
+ "RRF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_C | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+pCodeInstruction pciSUBWF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_SUBWF,
+ "SUBWF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z) // outCond
+};
+
+pCodeInstruction pciSUBFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_SUBWF,
+ "SUBWF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciSUBLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_SUBLW,
+ "SUBLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ (PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+pCodeInstruction pciSWAPF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_SWAPF,
+ "SWAPF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_REGISTER), // inCond
+ (PCC_REGISTER) // outCond
+};
+
+pCodeInstruction pciSWAPFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_SWAPFW,
+ "SWAPF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_REGISTER), // inCond
+ (PCC_W) // outCond
+};
+pCodeInstruction pciTRIS = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_TRIS,
+ "TRIS",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_NONE, // inCond
+ PCC_NONE
+};
+
+
+pCodeInstruction pciXORWF = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_XORWF,
+ "XORWF",
+ NULL, // operand
+ 2, // num ops
+ 1,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_REGISTER | PCC_Z) // outCond
+};
+
+pCodeInstruction pciXORFW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_XORWF,
+ "XORWF",
+ NULL, // operand
+ 2, // num ops
+ 0,0, // dest, bit instruction
+ (PCC_W | PCC_REGISTER), // inCond
+ (PCC_W | PCC_Z) // outCond
+};
+
+pCodeInstruction pciXORLW = {
+ {PC_OPCODE, NULL, NULL, 0, NULL, NULL, NULL, NULL,
+ genericAnalyze,
+ genericDestruct,
+ genericPrint},
+ POC_XORLW,
+ "XORLW",
+ NULL, // operand
+ 1, // num ops
+ 0,0, // dest, bit instruction
+ PCC_W, // inCond
+ (PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
+};
+
+
+#define MAX_PIC14MNEMONICS 100
+pCodeInstruction *pic14Mnemonics[MAX_PIC14MNEMONICS];
+
+/*-----------------------------------------------------------------*/
+/* SAFE_snprintf - like snprintf except the string pointer is */
+/* after the string has been printed to. This is */
+/* useful for printing to string as though if it */
+/* were a stream. */
+/*-----------------------------------------------------------------*/
+void SAFE_snprintf(char **str, size_t *size, const char *format, ...)
+{
+ va_list val;
+ int len;
+
+ if(!str || !*str)
+ return;
+
+ va_start(val, format);
+#if 0
+ // Alas, vsnprintf is not ANSI standard, and does not exist
+ // on Solaris (and probably other non-Gnu flavored Unixes).
+ vsnprintf(*str, *size, format, val);
+#else
+ // This, of course, is *not* safe, despite the name.
+ vsprintf(*str, format, val);
+#endif
+
+ va_end (val);
+
+ len = strlen(*str);
+ *str += len;
+ *size -= len;
+
+}
+
+void pCodeInitRegisters(void)
+{
+
+ pc_fsr.rIdx = 4;
+ pc_fsr.r = pic14_regWithIdx(4);
+
+}
+
+/*-----------------------------------------------------------------*/
+/* mnem2key - convert a pic mnemonic into a hash key */
+/* (BTW - this spreads the mnemonics quite well) */
+/* */
+/*-----------------------------------------------------------------*/
+
+int mnem2key(char const *mnem)
+{
+ int key = 0;
+
+ if(!mnem)
+ return 0;
+
+ while(*mnem) {
+
+ key += toupper(*mnem++) +1;
+
+ }
+
+ return (key & 0x1f);
+
+}
+
+void pic14initMnemonics(void)
+{
+ int i = 0;
+ int key;
+ // char *str;
+ pCodeInstruction *pci;
+
+ if(mnemonics_initialized)
+ return;
+
+ pic14Mnemonics[POC_ADDLW] = &pciADDLW;
+ pic14Mnemonics[POC_ADDWF] = &pciADDWF;
+ pic14Mnemonics[POC_ADDFW] = &pciADDFW;
+ pic14Mnemonics[POC_ANDLW] = &pciANDLW;
+ pic14Mnemonics[POC_ANDWF] = &pciANDWF;
+ pic14Mnemonics[POC_ANDFW] = &pciANDFW;
+ pic14Mnemonics[POC_BCF] = &pciBCF;
+ pic14Mnemonics[POC_BSF] = &pciBSF;
+ pic14Mnemonics[POC_BTFSC] = &pciBTFSC;
+ pic14Mnemonics[POC_BTFSS] = &pciBTFSS;
+ pic14Mnemonics[POC_CALL] = &pciCALL;
+ pic14Mnemonics[POC_COMF] = &pciCOMF;
+ pic14Mnemonics[POC_COMFW] = &pciCOMFW;
+ pic14Mnemonics[POC_CLRF] = &pciCLRF;
+ pic14Mnemonics[POC_CLRW] = &pciCLRW;
+ pic14Mnemonics[POC_DECF] = &pciDECF;
+ pic14Mnemonics[POC_DECFW] = &pciDECFW;
+ pic14Mnemonics[POC_DECFSZ] = &pciDECFSZ;
+ pic14Mnemonics[POC_DECFSZW] = &pciDECFSZW;
+ pic14Mnemonics[POC_GOTO] = &pciGOTO;
+ pic14Mnemonics[POC_INCF] = &pciINCF;
+ pic14Mnemonics[POC_INCFW] = &pciINCFW;
+ pic14Mnemonics[POC_INCFSZ] = &pciINCFSZ;
+ pic14Mnemonics[POC_INCFSZW] = &pciINCFSZW;
+ pic14Mnemonics[POC_IORLW] = &pciIORLW;
+ pic14Mnemonics[POC_IORWF] = &pciIORWF;
+ pic14Mnemonics[POC_IORFW] = &pciIORFW;
+ pic14Mnemonics[POC_MOVF] = &pciMOVF;
+ pic14Mnemonics[POC_MOVFW] = &pciMOVFW;
+ pic14Mnemonics[POC_MOVLW] = &pciMOVLW;
+ pic14Mnemonics[POC_MOVWF] = &pciMOVWF;
+ pic14Mnemonics[POC_NEGF] = &pciNEGF;
+ pic14Mnemonics[POC_RETLW] = &pciRETLW;
+ pic14Mnemonics[POC_RETURN] = &pciRETURN;
+ pic14Mnemonics[POC_RLF] = &pciRLF;
+ pic14Mnemonics[POC_RLFW] = &pciRLFW;
+ pic14Mnemonics[POC_RRF] = &pciRRF;
+ pic14Mnemonics[POC_RRFW] = &pciRRFW;
+ pic14Mnemonics[POC_SUBLW] = &pciSUBLW;
+ pic14Mnemonics[POC_SUBWF] = &pciSUBWF;
+ pic14Mnemonics[POC_SUBFW] = &pciSUBFW;
+ pic14Mnemonics[POC_SWAPF] = &pciSWAPF;
+ pic14Mnemonics[POC_SWAPFW] = &pciSWAPFW;
+ pic14Mnemonics[POC_TRIS] = &pciTRIS;
+ pic14Mnemonics[POC_XORLW] = &pciXORLW;
+ pic14Mnemonics[POC_XORWF] = &pciXORWF;
+ pic14Mnemonics[POC_XORFW] = &pciXORFW;
+
+ for(i=0; i<MAX_PIC14MNEMONICS; i++)
+ if(pic14Mnemonics[i])
+ hTabAddItem(&pic14MnemonicsHash, mnem2key(pic14Mnemonics[i]->mnemonic), pic14Mnemonics[i]);
+ pci = hTabFirstItem(pic14MnemonicsHash, &key);
+
+ while(pci) {
+ fprintf( stderr, "element %d key %d, mnem %s\n",i++,key,pci->mnemonic);
+ pci = hTabNextItem(pic14MnemonicsHash, &key);
+ }
+
+ mnemonics_initialized = 1;
+}
+
+int getpCode(char *mnem,unsigned dest)
+{
+
+ pCodeInstruction *pci;
+ int key = mnem2key(mnem);
+
+ if(!mnemonics_initialized)
+ pic14initMnemonics();
+
+ pci = hTabFirstItemWK(pic14MnemonicsHash, key);
+
+ while(pci) {
+
+ if(STRCASECMP(pci->mnemonic, mnem) == 0) {
+ if((pci->num_ops <= 1) || (pci->dest == dest))
+ return(pci->op);
+ }
+
+ pci = hTabNextItemWK (pic14MnemonicsHash);
+
+ }
+
+ return -1;
+}
+
+char getpBlock_dbName(pBlock *pb)
+{
+ if(!pb)
+ return 0;
+
+ if(pb->cmemmap)
+ return pb->cmemmap->dbName;
+
+ return pb->dbName;
+}
+/*-----------------------------------------------------------------*/
+/* movepBlock2Head - given the dbname of a pBlock, move all */
+/* instances to the front of the doubly linked */
+/* list of pBlocks */
+/*-----------------------------------------------------------------*/
+
+void movepBlock2Head(char dbName)
+{
+ pBlock *pb;
+
+ pb = the_pFile->pbHead;
+
+ while(pb) {
+
+ if(getpBlock_dbName(pb) == dbName) {
+ pBlock *pbn = pb->next;
+ pb->next = the_pFile->pbHead;
+ the_pFile->pbHead->prev = pb;
+ the_pFile->pbHead = pb;
+
+ if(pb->prev)
+ pb->prev->next = pbn;
+
+ // If the pBlock that we just moved was the last
+ // one in the link of all of the pBlocks, then we
+ // need to point the tail to the block just before
+ // the one we moved.
+ // Note: if pb->next is NULL, then pb must have
+ // been the last pBlock in the chain.
+
+ if(pbn)
+ pbn->prev = pb->prev;
+ else
+ the_pFile->pbTail = pb->prev;
+
+ pb = pbn;
+
+ } else
+ pb = pb->next;
+
+ }
+
+}