From f0914f906af64baca70034066af8fa475ef2c47f Mon Sep 17 00:00:00 2001 From: vrokas Date: Sat, 12 Jun 2004 14:18:45 +0000 Subject: [PATCH] * src/pic16/gen.c (genPointerGet): added E_INTERNAL_ERROR for default case in switch statement, * glue.c (pic16_initPointer): expr is initialised via decoarteType to eliminate problem with initialisation of pointers, but problem still exists, * (pic16_pointerTypeToGPByte): removed, no needed for pic16, * (emitStaticSegment): removed various lines emitting debug info, * src/pic16/pcode.c, src/pic16/pcode.h, src/pic16/ralloc.h: added processor registers for utilizing EEPROM, * src/pic16/pcode.c (pic16_emitDB): number of DBs emitted is not configurable and set 8 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3359 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 14 +++ src/pic16/device.c | 2 +- src/pic16/gen.c | 9 +- src/pic16/glue.c | 220 ++++++++++++++------------------------------- src/pic16/pcode.c | 37 ++++++-- src/pic16/pcode.h | 5 ++ src/pic16/ralloc.c | 31 ++----- src/pic16/ralloc.h | 6 ++ 8 files changed, 136 insertions(+), 188 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47f770c6..4f3c0d5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-06-12 Vangelis Rokas + + * src/pic16/gen.c (genPointerGet): added E_INTERNAL_ERROR for + default case in switch statement, + * glue.c (pic16_initPointer): expr is initialised via decoarteType + to eliminate problem with initialisation of pointers, but problem + still exists, + * (pic16_pointerTypeToGPByte): removed, no needed for pic16, + * (emitStaticSegment): removed various lines emitting debug info, + * src/pic16/pcode.c, src/pic16/pcode.h, src/pic16/ralloc.h: + added processor registers for utilizing EEPROM, + * src/pic16/pcode.c (pic16_emitDB): number of DBs emitted is not + configurable and set 8 + 2004-06-07 Vangelis Rokas * .version: increased version number to 2.4.2, diff --git a/src/pic16/device.c b/src/pic16/device.c index 730ea9e8..dab913ad 100644 --- a/src/pic16/device.c +++ b/src/pic16/device.c @@ -825,7 +825,7 @@ void pic16_groupRegistersInSection(set *regset) (reg->regop?(OP_SYMBOL(reg->regop)->level):-1) ); #endif - if(reg->alias) { + if(reg->alias == 0x80) { checkAddReg(&pic16_equ_data, reg); } else if(reg->isFixed) { diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 395abc91..6fbc8173 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -9642,11 +9642,13 @@ static void genConstPointerGet (operand *left, pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_tablat), pic16_popGet(AOP(result),offset))); offset++; } - // .... patch 15 + pic16_freeAsmop(left,NULL,ic,TRUE); pic16_freeAsmop(result,NULL,ic,TRUE); } + + /*-----------------------------------------------------------------*/ /* genPointerGet - generate code for pointer get */ /*-----------------------------------------------------------------*/ @@ -9733,6 +9735,11 @@ static void genPointerGet (iCode *ic) #endif genGenPointerGet (left,result,ic); break; + + default: + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "genPointerGet: illegal pointer type"); + } } diff --git a/src/pic16/glue.c b/src/pic16/glue.c index 2cc5b0dc..99f0c302 100644 --- a/src/pic16/glue.c +++ b/src/pic16/glue.c @@ -366,7 +366,8 @@ value *pic16_initPointer (initList * ilist, sym_link *toType) return valCastLiteral(toType, 0.0); } - expr = list2expr (ilist); + expr = decorateType(resolveSymbols( list2expr (ilist) ), FALSE); +// expr = list2expr( ilist ); if (!expr) goto wrong; @@ -406,7 +407,7 @@ value *pic16_initPointer (initList * ilist, sym_link *toType) if (IS_AST_SYM_VALUE (expr->left)) { val = copyValue (AST_VALUE (expr->left)); val->type = newLink (DECLARATOR); - if (SPEC_SCLS (expr->left->etype) == S_CODE) { + if(SPEC_SCLS (expr->left->etype) == S_CODE) { DCL_TYPE (val->type) = CPOINTER; DCL_PTR_CONST (val->type) = port->mem.code_ro; } @@ -420,6 +421,7 @@ value *pic16_initPointer (initList * ilist, sym_link *toType) DCL_TYPE (val->type) = EEPPOINTER; else DCL_TYPE (val->type) = POINTER; + val->type->next = expr->left->ftype; val->etype = getSpec (val->type); return val; @@ -483,6 +485,7 @@ value *pic16_initPointer (initList * ilist, sym_link *toType) val->etype = getSpec (val->type); return val; } + wrong: if (expr) werrorfl (expr->filename, expr->lineno, E_INCOMPAT_PTYPES); @@ -493,41 +496,6 @@ value *pic16_initPointer (initList * ilist, sym_link *toType) } -/*-----------------------------------------------------------------*/ -/* return the generic pointer high byte for a given pointer type. */ -/*-----------------------------------------------------------------*/ -int pic16_pointerTypeToGPByte (const int p_type, const char *iname, const char *oname) -{ - switch (p_type) - { - case IPOINTER: - case POINTER: - fprintf(stderr, "%s:%d pointer is IPOINTER/POINTER\n", __FILE__, __LINE__); - return GPTYPE_NEAR; - case GPOINTER: - fprintf(stderr, "%s:%d pointer is GPOINTER\n", __FILE__, __LINE__); - werror (E_CANNOT_USE_GENERIC_POINTER, - iname ? iname : "", - oname ? oname : ""); - exit (1); - case FPOINTER: - fprintf(stderr, "%s:%d pointer is FPOINTER\n", __FILE__, __LINE__); - return GPTYPE_FAR; - case CPOINTER: - fprintf(stderr, "%s:%d pointer is CPOINTER\n", __FILE__, __LINE__); - return GPTYPE_CODE; - case PPOINTER: - fprintf(stderr, "%s:%d pointer is PPOINTER\n", __FILE__, __LINE__); - return GPTYPE_XSTACK; - default: - fprintf (stderr, "*** internal error: unknown pointer type %d in GPByte.\n", - p_type); - break; - } - return -1; -} - - /*-----------------------------------------------------------------*/ /* printPointerType - generates ival for pointer type */ /*-----------------------------------------------------------------*/ @@ -553,11 +521,18 @@ void pic16_printPointerType (const char *name, char ptype, void *p) /*-----------------------------------------------------------------*/ /* printGPointerType - generates ival for generic pointer type */ /*-----------------------------------------------------------------*/ -void pic16_printGPointerType (const char *iname, const char *oname, +void pic16_printGPointerType (const char *iname, const char *oname, const unsigned int itype, const unsigned int type, char ptype, void *p) { _pic16_printPointerType (iname, ptype, p); - pic16_emitDB(pic16_pointerTypeToGPByte(type, iname, oname), ptype, p); + + if(itype == FPOINTER || itype == CPOINTER) { // || itype == GPOINTER) { + char buf[256]; + + sprintf(buf, "UPPER(%s)", iname); + pic16_emitDS(buf, ptype, p); + } + pic16_flushDB(ptype, p); } @@ -572,7 +547,7 @@ pic16_printIvalType (symbol *sym, sym_link * type, initList * ilist, char ptype, value *val; unsigned long ulval; - //fprintf(stderr, "%s\n",__FUNCTION__); +// fprintf(stderr, "%s for symbol %s\n",__FUNCTION__, sym->rname); /* if initList is deep */ if (ilist && ilist->type == INIT_DEEP) @@ -780,6 +755,7 @@ void pic16_printIvalBitFields(symbol **sym, initList **ilist, char ptype, void * default: /* VR - only 1,2,4 size long can be handled???? Why? */ fprintf(stderr, "%s:%d: unhandled case. Contact author.\n", __FILE__, __LINE__); + assert(0); } *sym = lsym; *ilist = lilist; @@ -834,7 +810,7 @@ int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char pty VR - Attempting to port this function to pic16 port - 8-Jun-2004 */ - fprintf(stderr, "%s\n",__FUNCTION__); +// fprintf(stderr, "%s\n",__FUNCTION__); size = getSize (type); @@ -844,11 +820,11 @@ int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char pty { pic16_emitDS(val->name, ptype, p); } - else if (size == FPTRSIZE) + else if (size == 2) { pic16_printPointerType (val->name, ptype, p); } - else if (size == GPTRSIZE) + else if (size == 3) { int type; if (IS_PTR (val->type)) { @@ -860,7 +836,7 @@ int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char pty // this is a literal string type=CPOINTER; } - pic16_printGPointerType(val->name, sym->name, type, ptype, p); + pic16_printGPointerType(val->name, sym->name, type, type, ptype, p); } else { @@ -874,45 +850,19 @@ int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char pty switch (size) { case 1: - pic16_emitDS(aopLiteral(val, 0), ptype, p); -// tfprintf (oFile, "\t!dbs\n", aopLiteral (val, 0)); + pic16_emitDB(pic16aopLiteral(val, 0), ptype, p); break; case 2: - pic16_emitDS(aopLiteral(val, 0), ptype, p); - pic16_emitDS(aopLiteral(val, 1), ptype, p); -// tfprintf (oFile, "\t.byte %s,%s\n", -// aopLiteral (val, 0), aopLiteral (val, 1)); + pic16_emitDB(pic16aopLiteral(val, 0), ptype, p); + pic16_emitDB(pic16aopLiteral(val, 1), ptype, p); break; case 3: - if (IS_GENPTR(type) && floatFromVal(val)!=0) { - // non-zero mcs51 generic pointer - werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC); - } - - pic16_emitDS(aopLiteral(val, 0), ptype, p); - pic16_emitDS(aopLiteral(val, 1), ptype, p); - pic16_emitDS(aopLiteral(val, 2), ptype, p); + pic16_emitDB(pic16aopLiteral(val, 0), ptype, p); + pic16_emitDB(pic16aopLiteral(val, 1), ptype, p); + pic16_emitDB(pic16aopLiteral(val, 2), ptype, p); -// fprintf (oFile, "\t.byte %s,%s,%s\n", -// aopLiteral (val, 0), -// aopLiteral (val, 1), -// aopLiteral (val, 2)); break; - -/* no 4 bytes size long for pic16 port */ - case 4: - if (IS_GENPTR(type) && floatFromVal(val)!=0) { - // non-zero ds390 generic pointer - werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC); - } - -// fprintf (oFile, "\t.byte %s,%s,%s,%s\n", -// aopLiteral (val, 0), -// aopLiteral (val, 1), -// aopLiteral (val, 2), -// aopLiteral (val, 3)); - break; default: assert (0); } @@ -960,14 +910,11 @@ void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void } /* now generate the name */ - if (!val->sym) - { + if (!val->sym) { pic16_printPointerType (val->name, ptype, p); - } - else - { + } else { pic16_printPointerType (val->sym->rname, ptype, p); - } + } return; } @@ -981,6 +928,12 @@ void pic16_printIvalPtr (symbol * sym, sym_link * type, initList * ilist, char p value *val; int size; + +#if 0 + fprintf(stderr, "%s:%d initialising pointer: %s size: %d\n", __FILE__, __LINE__, + sym->rname, getSize(sym->type)); +#endif + /* if deep then */ if (ilist && (ilist->type == INIT_DEEP)) ilist = ilist->init.deep; @@ -1013,22 +966,14 @@ void pic16_printIvalPtr (symbol * sym, sym_link * type, initList * ilist, char p { case 1: pic16_emitDB((unsigned int)floatFromVal(val) & 0xff, ptype, p); -// tfprintf (oFile, "\t!db !constbyte\n", (unsigned int) floatFromVal (val) & 0xff); break; case 2: pic16_emitDB(pic16aopLiteral(val, 0), ptype, p); pic16_emitDB(pic16aopLiteral(val, 1), ptype, p); -// tfprintf (oFile, "\t.byte %s,%s\n", aopLiteral (val, 0), aopLiteral (val, 1)); break; case 3: pic16_emitDB(pic16aopLiteral(val, 0), ptype, p); pic16_emitDB(pic16aopLiteral(val, 1), ptype, p); - - if (IS_GENPTR (val->type)) - pic16_emitDB(pic16aopLiteral(val, 2), ptype, p); - else if (IS_PTR (val->type)) - pic16_emitDB(pic16_pointerTypeToGPByte(DCL_TYPE(val->type), NULL, NULL), ptype, p); - else pic16_emitDB(pic16aopLiteral(val, 2), ptype, p); } return; @@ -1041,13 +986,13 @@ void pic16_printIvalPtr (symbol * sym, sym_link * type, initList * ilist, char p { pic16_emitDS(val->name, ptype, p); } - else if (size == FPTRSIZE) + else if (size == 2) { pic16_printPointerType (val->name, ptype, p); } - else if (size == GPTRSIZE) + else if (size == 3) { - pic16_printGPointerType (val->name, sym->name, + pic16_printGPointerType (val->name, sym->name, (IS_PTR(type)?DCL_TYPE(type):PTR_TYPE(SPEC_OCLS(sym->etype))), (IS_PTR (val->type) ? DCL_TYPE (val->type) : PTR_TYPE (SPEC_OCLS (val->etype))), ptype, p); } @@ -1068,15 +1013,15 @@ void pic16_printIval (symbol * sym, sym_link * type, initList * ilist, char ptyp // fprintf(stderr, "%s:%d generating init for %s\n", __FILE__, __LINE__, sym->name); - /* if structure then */ + /* if structure then */ if (IS_STRUCT (type)) { - fprintf(stderr,"%s struct\n",__FUNCTION__); +// fprintf(stderr,"%s struct\n",__FUNCTION__); pic16_printIvalStruct (sym, type, ilist, ptype, p); return; } - /* if this is an array */ + /* if this is an array */ if (IS_ARRAY (type)) { // fprintf(stderr,"%s array\n",__FUNCTION__); @@ -1098,7 +1043,7 @@ void pic16_printIval (symbol * sym, sym_link * type, initList * ilist, char ptyp } } -#if 1 +#if 0 // and the type must match itype=ilist->init.node->ftype; @@ -1120,7 +1065,7 @@ void pic16_printIval (symbol * sym, sym_link * type, initList * ilist, char ptyp /* if this is a pointer */ if (IS_PTR (type)) { - fprintf(stderr,"%s pointer\n",__FUNCTION__); +// fprintf(stderr,"%s pointer\n",__FUNCTION__); pic16_printIvalPtr (sym, type, ilist, ptype, p); return; } @@ -1171,7 +1116,6 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", #endif if(SPEC_ABSA(sym->etype) && PIC16_IS_CONFIG_ADDRESS(SPEC_ADDR(sym->etype))) { - pic16_assignConfigWordValue(SPEC_ADDR(sym->etype), (int) floatFromVal(list2val(sym->ival))); @@ -1179,12 +1123,8 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", } /* if it is "extern" then do nothing */ - if (IS_EXTERN (sym->etype)) { - - /* do not emit if it is a config word declaration */ - if(!SPEC_ABSA(sym->etype) - || (SPEC_ABSA(sym->etype) && !PIC16_IS_CONFIG_ADDRESS(SPEC_ADDR(sym->etype)))) - checkAddSym(&externs, sym); + if (IS_EXTERN (sym->etype) && !SPEC_ABSA(sym->etype)) { + checkAddSym(&externs, sym); continue; } @@ -1195,44 +1135,18 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", checkAddSym(&publics, sym); } -#if 0 /* print extra debug info if required */ - if (options.debug || sym->level == 0) - { + if (options.debug || sym->level == 0) { /* NOTE to me - cdbFile may be null in which case, * the sym name will be printed to stdout. oh well */ - if(cdbFile) - cdbSymbol (sym, cdbFile, FALSE, FALSE); - - if (!sym->level) - { /* global */ - if (IS_STATIC (sym->etype)) - fprintf (code->oFile, "F%s_", moduleName); /* scope is file */ - else - fprintf (code->oFile, "G_"); /* scope is global */ - } - else - /* symbol is local */ - fprintf (code->oFile, "L%s_", - (sym->localof ? sym->localof->name : "-null-")); - fprintf (code->oFile, "%s_%d_%d", sym->name, sym->level, sym->block); - - } -#endif - + debugFile->writeSymbol(sym); + } + /* if it has an absolute address */ - if (SPEC_ABSA (sym->etype)) - { - fprintf(stderr, "%s:%d spec_absa is true for symbol: %s\n", - __FILE__, __LINE__, sym->name); + if (SPEC_ABSA (sym->etype)) { +// fprintf(stderr, "%s:%d spec_absa is true for symbol: %s\n", +// __FILE__, __LINE__, sym->name); - if (options.debug || sym->level == 0) - fprintf (code->oFile, " == 0x%04x\n", SPEC_ADDR (sym->etype)); - - fprintf (code->oFile, "%s\t=\t0x%04x\n", - sym->rname, - SPEC_ADDR (sym->etype)); - /* if it has an initial value */ if (sym->ival) { @@ -1241,6 +1155,7 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", absSym *abSym; pCode *pcf; + /* symbol has absolute address and initial value */ noAlloc++; resolveIvalSym (sym->ival, sym->type); asym = newSymbol(sym->rname, 0); @@ -1266,31 +1181,30 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", else { + /* symbol has absolute address but no initial value */ + /* allocate space */ fprintf (code->oFile, "%s:\n", sym->rname); + /* special case for character strings */ if (IS_ARRAY (sym->type) && IS_CHAR (sym->type->next) && SPEC_CVAL (sym->etype).v_char) pic16_pCodeConstString(sym->rname , SPEC_CVAL (sym->etype).v_char); - /*printChar (code->oFile, - SPEC_CVAL (sym->etype).v_char, - strlen (SPEC_CVAL (sym->etype).v_char) + 1);*/ - else + else { + assert(0); fprintf (code->oFile, "\t.ds\t0x%04x\n", (unsigned int) getSize (sym->type) & 0xffff); + } } } else { // fprintf(stderr, "%s:%d spec_absa is false for symbol: %s\n", // __FILE__, __LINE__, sym->name); - if (options.debug || sym->level == 0) - fprintf (code->oFile, " == .\n"); - /* if it has an initial value */ - if (sym->ival) - { + if (sym->ival) { pBlock *pb; + /* symbol doesn't have absolute address but has initial value */ fprintf (code->oFile, "%s:\n", sym->rname); noAlloc++; resolveIvalSym (sym->ival, sym->type); @@ -1302,21 +1216,19 @@ CODESPACE: %d\tCONST: %d\tPTRCONST: %d\tSPEC_CONST: %d\n", pic16_printIval(sym, sym->type, sym->ival, 'p', (void *)pb); pic16_flushDB('p', (void *)pb); noAlloc--; - } - else - { + } else { + /* symbol doesn't have absolute address and no initial value */ /* allocate space */ fprintf (code->oFile, "%s:\n", sym->rname); /* special case for character strings */ if (IS_ARRAY (sym->type) && IS_CHAR (sym->type->next) && SPEC_CVAL (sym->etype).v_char) pic16_pCodeConstString(sym->rname , SPEC_CVAL (sym->etype).v_char); - /*printChar (code->oFile, - SPEC_CVAL (sym->etype).v_char, - strlen (SPEC_CVAL (sym->etype).v_char) + 1);*/ - else + else { + assert(0); fprintf (code->oFile, "\t.ds\t0x%04x\n", (unsigned int) getSize (sym->type) & 0xffff); + } } } } diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index dc8360e8..8db953bb 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -100,6 +100,14 @@ pCodeOpReg pic16_pc_plusw2 = {{PO_INDF0, "PLUSW2"}, -1, NULL, 0, NULL}; pCodeOpReg pic16_pc_prodl = {{PO_PRODL, "PRODL"}, -1, NULL, 0, NULL}; pCodeOpReg pic16_pc_prodh = {{PO_PRODH, "PRODH"}, -1, NULL, 0, NULL}; +/* EEPROM registers */ +pCodeOpReg pic16_pc_eecon1 = {{PO_SFR_REGISTER, "EECON1"}, -1, NULL, 0, NULL}; +pCodeOpReg pic16_pc_eecon2 = {{PO_SFR_REGISTER, "EECON2"}, -1, NULL, 0, NULL}; +pCodeOpReg pic16_pc_eedata = {{PO_SFR_REGISTER, "EEDATA"}, -1, NULL, 0, NULL}; +pCodeOpReg pic16_pc_eeadr = {{PO_SFR_REGISTER, "EEADR"}, -1, NULL, 0, NULL}; + + + pCodeOpReg pic16_pc_kzero = {{PO_GPR_REGISTER, "KZ"}, -1, NULL,0,NULL}; pCodeOpReg pic16_pc_wsave = {{PO_GPR_REGISTER, "WSAVE"}, -1, NULL,0,NULL}; pCodeOpReg pic16_pc_ssave = {{PO_GPR_REGISTER, "SSAVE"}, -1, NULL,0,NULL}; @@ -2784,13 +2792,10 @@ void pic16_pCodeInitRegisters(void) pic16_pc_tosh.r = pic16_allocProcessorRegister(IDX_TOSH,"TOSH", PO_SFR_REGISTER, 0x80); pic16_pc_tosu.r = pic16_allocProcessorRegister(IDX_TOSU,"TOSU", PO_SFR_REGISTER, 0x80); - pic16_pc_tblptrl.r = pic16_allocProcessorRegister(IDX_TBLPTRL,"TBLPTRL", PO_SFR_REGISTER, 0x80); // patch 15 - pic16_pc_tblptrh.r = pic16_allocProcessorRegister(IDX_TBLPTRH,"TBLPTRH", PO_SFR_REGISTER, 0x80); // patch 15 - pic16_pc_tblptru.r = pic16_allocProcessorRegister(IDX_TBLPTRU,"TBLPTRU", PO_SFR_REGISTER, 0x80); // patch 15 - pic16_pc_tablat.r = pic16_allocProcessorRegister(IDX_TABLAT,"TABLAT", PO_SFR_REGISTER, 0x80); // patch 15 - - -// pic16_pc_fsr0.r = pic16_allocProcessorRegister(IDX_FSR0,"FSR0", PO_FSR0, 0x80); // deprecated ! + pic16_pc_tblptrl.r = pic16_allocProcessorRegister(IDX_TBLPTRL,"TBLPTRL", PO_SFR_REGISTER, 0x80); + pic16_pc_tblptrh.r = pic16_allocProcessorRegister(IDX_TBLPTRH,"TBLPTRH", PO_SFR_REGISTER, 0x80); + pic16_pc_tblptru.r = pic16_allocProcessorRegister(IDX_TBLPTRU,"TBLPTRU", PO_SFR_REGISTER, 0x80); + pic16_pc_tablat.r = pic16_allocProcessorRegister(IDX_TABLAT,"TABLAT", PO_SFR_REGISTER, 0x80); pic16_pc_fsr0l.r = pic16_allocProcessorRegister(IDX_FSR0L, "FSR0L", PO_FSR0, 0x80); pic16_pc_fsr0h.r = pic16_allocProcessorRegister(IDX_FSR0H, "FSR0H", PO_FSR0, 0x80); @@ -2819,6 +2824,13 @@ void pic16_pCodeInitRegisters(void) pic16_pc_prodl.r = pic16_allocProcessorRegister(IDX_PRODL, "PRODL", PO_PRODL, 0x80); pic16_pc_prodh.r = pic16_allocProcessorRegister(IDX_PRODH, "PRODH", PO_PRODH, 0x80); + + + pic16_pc_eecon1.r = pic16_allocProcessorRegister(IDX_EECON1, "EECON1", PO_SFR_REGISTER, 0x80); + pic16_pc_eecon2.r = pic16_allocProcessorRegister(IDX_EECON2, "EECON2", PO_SFR_REGISTER, 0x80); + pic16_pc_eedata.r = pic16_allocProcessorRegister(IDX_EEDATA, "EEDATA", PO_SFR_REGISTER, 0x80); + pic16_pc_eeadr.r = pic16_allocProcessorRegister(IDX_EEADR, "EEADR", PO_SFR_REGISTER, 0x80); + pic16_pc_status.rIdx = IDX_STATUS; pic16_pc_intcon.rIdx = IDX_INTCON; @@ -2870,6 +2882,12 @@ void pic16_pCodeInitRegisters(void) pic16_pc_wsave.rIdx = IDX_WSAVE; pic16_pc_ssave.rIdx = IDX_SSAVE; + pic16_pc_eecon1.rIdx = IDX_EECON1; + pic16_pc_eecon2.rIdx = IDX_EECON2; + pic16_pc_eedata.rIdx = IDX_EEDATA; + pic16_pc_eeadr.rIdx = IDX_EEADR; + + /* probably should put this in a separate initialization routine */ pb_dead_pcodes = newpBlock(); @@ -4025,6 +4043,7 @@ pCodeOp *pic16_newpCodeOp(char *name, PIC_OPTYPE type) return pcop; } +#define DB_ITEMS_PER_LINE 8 typedef struct DBdata { @@ -4086,7 +4105,7 @@ void pic16_emitDB(char c, char ptype, void *p) sprintf(DBd.buffer+l,"%s0x%02x", (DBd.count>0?", ":""), c & 0xff); DBd.count++; - if (DBd.count>=16) + if (DBd.count>= DB_ITEMS_PER_LINE) pic16_flushDB(ptype, p); } @@ -6430,6 +6449,8 @@ static void pic16_FixRegisterBanking(pBlock *pb) prevreg = reg; if(!pic16_options.no_banksel) insertBankSwitch(0, pc); + } else { +// if(pcprev && isPCI_SKIP(pcprev))assert(0); } } diff --git a/src/pic16/pcode.h b/src/pic16/pcode.h index fd0516e3..f6ca309a 100644 --- a/src/pic16/pcode.h +++ b/src/pic16/pcode.h @@ -983,6 +983,11 @@ 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 */ extern pCodeOpReg pic16_pc_ssave; /* registers during an interrupt */ diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index 7d5e782d..eda8b769 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -656,7 +656,7 @@ pic16_allocDirReg (operand *op ) return NULL; } - if(1) { //!PIC16_IS_CONFIG_ADDRESS(address)) { + if(1) { //!PIC16_IS_CONFIG_ADDRESS(address)) // fprintf(stderr,"%s:allocating new reg %s\n",__FUNCTION__, name); /* this is an error, why added? -- VR */ @@ -672,23 +672,22 @@ pic16_allocDirReg (operand *op ) if(!IN_DIRSPACE( SPEC_OCLS( OP_SYM_ETYPE(op)))) { // patch 13 if(pic16_debug_verbose) // { // - fprintf(stderr, "dispace:%d farspace:%d codespace:%d regspace:%d stack:%d\n", + fprintf(stderr, "dispace:%d farspace:%d codespace:%d regspace:%d stack:%d eeprom: %d\n", IN_DIRSPACE( SPEC_OCLS( OP_SYM_ETYPE(op))), IN_FARSPACE( SPEC_OCLS( OP_SYM_ETYPE(op))), IN_CODESPACE( SPEC_OCLS( OP_SYM_ETYPE(op))), IN_REGSP( SPEC_OCLS( OP_SYM_ETYPE(op))), - IN_STACK( OP_SYM_ETYPE(op))); + IN_STACK( OP_SYM_ETYPE(op)), + SPEC_OCLS(OP_SYM_ETYPE(op)) == eeprom); fprintf(stderr, "%s:%d symbol %s NOT in dirspace\n", __FILE__, __LINE__, // OP_SYMBOL(op)->name); // } // -// return NULL; // } // patch 13 reg = newReg(regtype, PO_DIR, rDirectIdx++, name,getSize (OP_SYMBOL (op)->type),0, op); debugLog ("%d -- added %s to hash, size = %d\n", __LINE__, name,reg->size); -// hTabAddItem(&dynDirectRegNames, regname2key(name), reg); /* commented out */ // if (SPEC_ABSA ( OP_SYM_ETYPE(op)) ) { // fprintf(stderr, " ralloc.c at fixed address: %s - changing to REG_SFR\n",name); @@ -707,7 +706,6 @@ pic16_allocDirReg (operand *op ) } else { debugLog (" -- %s is declared at address 0x30000x\n",name); -// fprintf(stderr, " -- %s is declared at address 0x30000x\n",name); return NULL; } @@ -1115,31 +1113,16 @@ void pic16_writeUsedRegs(FILE *of) pic16_groupRegistersInSection(pic16_dynProcessorRegs); -#if 0 - pic16_assignFixedRegisters(pic16_dynAllocRegs); - pic16_assignFixedRegisters(pic16_dynStackRegs); - pic16_assignFixedRegisters(pic16_dynDirectRegs); - pic16_assignFixedRegisters(pic16_dynProcessorRegs); - - pic16_assignRelocatableRegisters(pic16_dynDirectBitRegs, 0); - pic16_assignRelocatableRegisters(pic16_dynInternalRegs,0); - pic16_assignRelocatableRegisters(pic16_dynAllocRegs,0); - pic16_assignRelocatableRegisters(pic16_dynStackRegs,0); - pic16_assignRelocatableRegisters(pic16_dynDirectRegs,0); -#endif - -// pic16_dump_map(); -// pic16_dump_cblock(of); - /* dump equates */ pic16_dump_equates(of, pic16_equ_data); +// pic16_dump_esection(of, pic16_rel_eedata, 0); +// pic16_dump_esection(of, pic16_fix_eedata, 0); + /* dump initialised data */ pic16_dump_isection(of, rel_idataSymSet, 0); pic16_dump_isection(of, fix_idataSymSet, 1); -// pic16_dump_idata(of, idataSymSet); - /* dump internal registers */ pic16_dump_int_registers(of, pic16_int_regs); diff --git a/src/pic16/ralloc.h b/src/pic16/ralloc.h index 730d261e..e2ab7d37 100644 --- a/src/pic16/ralloc.h +++ b/src/pic16/ralloc.h @@ -169,6 +169,12 @@ regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alia #define IDX_PRODL 0xff3 #define IDX_PRODH 0xff4 +/* EEPROM registers */ +#define IDX_EECON1 0xfa6 +#define IDX_EECON2 0xfa7 +#define IDX_EEDATA 0xfa8 +#define IDX_EEADR 0xfa9 + #define IDX_KZ 0x7fff /* Known zero - actually just a general purpose reg. */ #define IDX_WSAVE 0x7ffe #define IDX_SSAVE 0x7ffd -- 2.47.2