X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fpic16%2Fdevice.c;h=8878ed0799935e17bef44c6935179b32d819da93;hb=5e18c799d15ef505b96b2c369885b06a75e36625;hp=294fc187bc79789be7b9d059677512d0d00ee113;hpb=3e6a1de6a8b8e4031ce47445eb9bebed88a283b7;p=fw%2Fsdcc diff --git a/src/pic16/device.c b/src/pic16/device.c index 294fc187..8878ed07 100644 --- a/src/pic16/device.c +++ b/src/pic16/device.c @@ -35,192 +35,29 @@ #include "newalloc.h" +#include "main.h" #include "pcode.h" #include "ralloc.h" #include "device.h" static PIC16_device Pics16[] = { - { - {"p18f242", "18f242", "pic18f242", "f242"}, // aliases - 0, - 0x300, // bank mask - 0x300, // RAMsize - 0 - }, - - { - {"p18f252", "18f252", "pic18f252", "f252"}, // aliases - 0, - 0x600, // bank mask - 0x600, // RAMsize - 0 - }, - - { - {"p18f442", "18f442", "pic18f442", "f442"}, // aliases - 0, - 0x300, // bank mask - 0x300, // RAMsize - 0 - }, - - { - {"p18f452", "18f452", "pic18f452", "f452"}, // aliases - 0, - 0x600, // bank mask - 0x600, // RAMsize - 0 - }, - - { - {"p18f248", "18f248", "pic18f248", "f248"}, // aliases - 0, - 0x300, // bank mask - 0x300, // RAMsize - 0 - }, - - { - {"p18f258", "18f258", "pic18f258", "f258"}, // aliases - 0, - 0x600, // bank mask - 0x600, // RAMsize - 0 - }, - - { - {"p18f448", "18f448", "pic18f448", "f448"}, // aliases - 0, - 0x300, // bank mask - 0x300, // RAMsize - 0 - }, - - { - {"p18f458", "18f458", "pic18f458", "f458"}, // aliases - 0, - 0x600, // bank mask - 0x600, // RAMsize - 0 - }, - - { - {"p18f6520", "18f6520", "pic18f6520", "f6520"}, // aliases - 0, - 0x800, // bank mask - 0x800, // RAMsize - 1 - }, - - { - {"p18f6620", "18f6620", "pic18f6620", "f6620"}, // aliases - 0, - 0xf00, // bank mask - 0xf00, // RAMsize - 1 - }, - { - {"p18f6680", "18f6680", "pic18f6680", "f6680"}, // aliases - 0, - 0xc00, // bank mask - 0xc00, // RAMsize - 1 - }, - { - {"p18f6720", "18f6720", "pic18f6720", "f6720"}, // aliases - 0, - 0xf00, // bank mask - 0xf00, // RAMsize - 1 - }, - { - {"p18f8520", "18f8520", "pic18f8520", "f8520"}, // aliases - 0, - 0x800, // bank mask - 0x800, // RAMsize - 1 - }, - { - {"p18f8620", "18f8620", "pic18f8620", "f8620"}, // aliases - 0, - 0xf00, // bank mask - 0xf00, // RAMsize - 1 - }, - { - {"p18f8680", "18f8680", "pic18f8680", "f8680"}, // aliases - 0, - 0xc00, // bank mask - 0x800, // RAMsize - 1 - }, - { - {"p18f8720", "18f8720", "pic18f8720", "f8720"}, // aliases - 0, - 0xf00, // bank mask - 0xf00, // RAMsize - 1 - }, - +/* Device descriptions are now generated by scripts. + * For simplicities sake we just include them here. + * Manual overrides may be inserted on top of devices.inc + * or right here BEFORE inclusion of devices.inc. */ +#include "devices.inc" }; static int num_of_supported_PICS = sizeof(Pics16)/sizeof(PIC16_device); +stats_t statistics = { 0, 0, 0, 0 }; + #define DEFAULT_PIC "452" PIC16_device *pic16=NULL; - -#define DEFAULT_CONFIG_BYTE 0xff - -#define CONFIG1H_WORD_ADDRESS 0x300001 -#define DEFAULT_CONFIG1H_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG2L_WORD_ADDRESS 0x300002 -#define DEFAULT_CONFIG2L_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG2H_WORD_ADDRESS 0x300003 -#define DEFAULT_CONFIG2H_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG3H_WORD_ADDRESS 0x300005 -#define DEFAULT_CONFIG3H_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG4L_WORD_ADDRESS 0x300006 -#define DEFAULT_CONFIG4L_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG5L_WORD_ADDRESS 0x300008 -#define DEFAULT_CONFIG5L_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG5H_WORD_ADDRESS 0x300009 -#define DEFAULT_CONFIG5H_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG6L_WORD_ADDRESS 0x30000a -#define DEFAULT_CONFIG6L_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG6H_WORD_ADDRESS 0x30000b -#define DEFAULT_CONFIG6H_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG7L_WORD_ADDRESS 0x30000c -#define DEFAULT_CONFIG7L_WORD DEFAULT_CONFIG_BYTE - -#define CONFIG7H_WORD_ADDRESS 0x30000d -#define DEFAULT_CONFIG7H_WORD DEFAULT_CONFIG_BYTE - -static unsigned int config1h_word = DEFAULT_CONFIG1H_WORD; -static unsigned int config2l_word = DEFAULT_CONFIG2L_WORD; -static unsigned int config2h_word = DEFAULT_CONFIG2H_WORD; -static unsigned int config3h_word = DEFAULT_CONFIG3H_WORD; -static unsigned int config4l_word = DEFAULT_CONFIG4L_WORD; -static unsigned int config5l_word = DEFAULT_CONFIG5L_WORD; -static unsigned int config5h_word = DEFAULT_CONFIG5H_WORD; -static unsigned int config6l_word = DEFAULT_CONFIG6L_WORD; -static unsigned int config6h_word = DEFAULT_CONFIG6H_WORD; -static unsigned int config7l_word = DEFAULT_CONFIG7L_WORD; -static unsigned int config7h_word = DEFAULT_CONFIG7H_WORD; - unsigned int stackPos = 0; - -extern regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias, operand *refop); +unsigned int stackLen = 0; void pic16_setMaxRAM(int size) { @@ -253,6 +90,25 @@ void pic16_dump_equates(FILE *of, set *equs) } +void pic16_dump_access(FILE *of, set *section) +{ + regs *r; + + r = setFirstItem(section); + if(!r)return; + + fprintf(of, "%s", iComments2); + fprintf(of, ";\tAccess bank symbols\n"); + fprintf(of, "%s", iComments2); + + fprintf(of, "\tudata_acs\n"); + for(; r; r = setNextItem(section)) { + fprintf(of, "%s\tres\t%d\n", r->name, r->size); + statistics.adsize += r->size; + } +} + + int regCompare(const void *a, const void *b) { const regs *const *i = a; @@ -263,25 +119,47 @@ int regCompare(const void *a, const void *b) if( (*i)->address < (*j)->address)return -1; /* and secondarily by size */ + /* register size sorting may have strange results use with care */ if( (*i)->size > (*j)->size)return 1; if( (*i)->size < (*j)->size)return -1; - /* register size sorting may have strange results use with care */ - /* finally if in same address and same size sort by name */ return (strcmp( (*i)->name, (*j)->name)); return 0; } -void pic16_dump_section(FILE *of, set *section, int fix) +int symCompare(const void *a, const void *b) +{ + const symbol *const *i = a; + const symbol *const *j = b; + + /* sort primarily by the address */ + if( SPEC_ADDR((*i)->etype) > SPEC_ADDR((*j)->etype))return 1; + if( SPEC_ADDR((*i)->etype) < SPEC_ADDR((*j)->etype))return -1; + + /* and secondarily by size */ + /* register size sorting may have strange results use with care */ + if( getSize((*i)->etype) > getSize((*j)->etype))return 1; + if( getSize((*i)->etype) < getSize((*j)->etype))return -1; + + /* finally if in same address and same size sort by name */ + return (strcmp( (*i)->rname, (*j)->rname)); + + return 0; +} + +void pic16_dump_usection(FILE *of, set *section, int fix) { - static int abs_section_no=0; + static int abs_usection_no=0; + static unsigned int usection_no=0; regs *r, *rprev; - int init_addr, i; + unsigned int init_addr, i; regs **rlist; + regs *r1; /* put all symbols in an array */ + if (!elementsInSet(section)) return; rlist = Safe_calloc(elementsInSet(section), sizeof(regs *)); r = rlist[0]; i = 0; for(rprev = setFirstItem(section); rprev; rprev = setNextItem(section)) { @@ -289,7 +167,7 @@ void pic16_dump_section(FILE *of, set *section, int fix) } if(!i) { - if(rlist)free(rlist); + if(rlist)Safe_free(rlist); return; } @@ -297,42 +175,167 @@ void pic16_dump_section(FILE *of, set *section, int fix) qsort(rlist, i /*elementsInSet(section)*/, sizeof(regs *), regCompare); if(!fix) { + +#define EMIT_SINGLE_UDATA_SECTION 0 +#if EMIT_SINGLE_UDATA_SECTION fprintf(of, "\n\n\tudata\n"); for(r = setFirstItem(section); r; r = setNextItem(section)) { fprintf(of, "%s\tres\t%d\n", r->name, r->size); + statistics.udsize += r->size; + } +#else + for(r = setFirstItem(section); r; r = setNextItem(section)) { + //fprintf(of, "\nudata_%s_%s\tudata\n", moduleName, r->name); + fprintf(of, "\nudata_%s_%u\tudata\n", moduleName, usection_no++); + fprintf(of, "%s\tres\t%d\n", r->name, r->size); + statistics.udsize += r->size; } +#endif } else { - int j=0; - regs *r1; - + unsigned int j=0; + int deb_addr=0; + rprev = NULL; init_addr = rlist[j]->address; - fprintf(of, "\n\nstatic_%s_%02d\tudata\t0X%04X\n", moduleName, abs_section_no++, init_addr); + deb_addr = init_addr; + fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, init_addr); for(j=0;jaddress; - - if(rprev && (init_addr != (rprev->address + rprev->size)) - && !(r1 && (init_addr != r1->address))) { - fprintf(of, "\nstatic_%s_%02d\tudata\t0X%04X\n", moduleName, abs_section_no++, init_addr); + deb_addr = init_addr; + + if((rprev && (init_addr > (rprev->address + rprev->size)))) { + fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, init_addr); } - if(r1 && (init_addr == r1->address)) { - fprintf(of, "%s\tres\t0\n\n", r->name); + fprintf(of, "\n%s\tres\t0\n", r->name); } else { fprintf(of, "%s\tres\t%d\n", r->name, r->size); + deb_addr += r->size; + statistics.udsize += r->size; } rprev = r; } } - free(rlist); + Safe_free(rlist); +} + +void pic16_dump_gsection(FILE *of, set *sections) +{ + regs *r; + sectName *sname; + + for(sname = setFirstItem(sections); sname; sname = setNextItem(sections)) { + if(!strcmp(sname->name, "access"))continue; + fprintf(of, "\n\n%s\tudata\n", sname->name); + + for(r=setFirstItem(sname->regsSet); r; r=setNextItem(sname->regsSet)) { +#if 0 + fprintf(stderr, "%s:%d emitting variable %s for section %s (%p)\n", __FILE__, __LINE__, + r->name, sname->name, sname); +#endif + fprintf(of, "%s\tres\t%d\n", r->name, r->size); + statistics.udsize += r->size; + } + } +} + + +/* forward declaration */ +void pic16_printIval(symbol * sym, sym_link * type, initList * ilist, char ptype, void *p); +extern void pic16_pCodeConstString(char *name, char *value); + +void pic16_dump_isection(FILE *of, set *section, int fix) +{ + static int abs_isection_no=0; + symbol *s, *sprev; + unsigned int init_addr, i; + symbol **slist; + + /* put all symbols in an array */ + if (!elementsInSet(section)) return; + slist = Safe_calloc(elementsInSet(section), sizeof(symbol *)); + s = slist[0]; i = 0; + for(sprev = setFirstItem(section); sprev; sprev = setNextItem(section)) { + slist[i] = sprev; i++; + } + + if(!i) { + if(slist)Safe_free(slist); + return; + } + + /* sort symbols according to their address */ + qsort(slist, i, sizeof(symbol *), symCompare); + + pic16_initDB(); + + if(!fix) { + fprintf(of, "\n\n\tidata\n"); + for(s = setFirstItem(section); s; s = setNextItem(section)) { + + if(s->ival) { + fprintf(of, "%s", s->rname); + pic16_printIval(s, s->type, s->ival, 'f', (void *)of); + pic16_flushDB('f', (void *)of); + } else { + if (IS_ARRAY (s->type) && IS_CHAR (s->type->next) + && SPEC_CVAL (s->etype).v_char) { + +// fprintf(stderr, "%s:%d printing code string from %s\n", __FILE__, __LINE__, s->rname); + pic16_pCodeConstString(s->rname , SPEC_CVAL (s->etype).v_char); + } else { + assert(0); + } + } + + } + } else { + unsigned int j=0; + symbol *s1; + + sprev = NULL; + init_addr = SPEC_ADDR(slist[j]->etype); + fprintf(of, "\n\nistat_%s_%02d\tidata\t0X%04X\n", moduleName, abs_isection_no++, init_addr); + + for(j=0;jetype); + + if(sprev && (init_addr > (SPEC_ADDR(sprev->etype) + getSize(sprev->etype)))) { + fprintf(of, "\nistat_%s_%02d\tidata\t0X%04X\n", moduleName, abs_isection_no++, init_addr); + } + + if(s->ival) { + fprintf(of, "%s", s->rname); + pic16_printIval(s, s->type, s->ival, 'f', (void *)of); + pic16_flushDB('f', (void *)of); + } else { + if (IS_ARRAY (s->type) && IS_CHAR (s->type->next) + && SPEC_CVAL (s->etype).v_char) { + +// fprintf(stderr, "%s:%d printing code string from %s\n", __FILE__, __LINE__, s->rname); + pic16_pCodeConstString(s->rname , SPEC_CVAL (s->etype).v_char); + } else { + assert(0); + } + } + + + sprev = s; + } + } + Safe_free(slist); } + void pic16_dump_int_registers(FILE *of, set *section) { regs *r, *rprev; @@ -340,6 +343,7 @@ void pic16_dump_int_registers(FILE *of, set *section) regs **rlist; /* put all symbols in an array */ + if (!elementsInSet(section)) return; rlist = Safe_calloc(elementsInSet(section), sizeof(regs *)); r = rlist[0]; i = 0; for(rprev = setFirstItem(section); rprev; rprev = setNextItem(section)) { @@ -350,17 +354,19 @@ void pic16_dump_int_registers(FILE *of, set *section) qsort(rlist, elementsInSet(section), sizeof(regs *), regCompare); if(!i) { - if(rlist)free(rlist); + if(rlist)Safe_free(rlist); return; } fprintf(of, "\n\n; Internal registers\n"); fprintf(of, "%s\tudata_ovr\t0x0000\n", ".registers"); - for(r = setFirstItem(section); r; r = setNextItem(section)) + for(r = setFirstItem(section); r; r = setNextItem(section)) { fprintf(of, "%s\tres\t%d\n", r->name, r->size); + statistics.intsize += r->size; + } - free(rlist); + Safe_free(rlist); } @@ -370,128 +376,6 @@ void pic16_dump_int_registers(FILE *of, set *section) #define _ENDIAN(x) (x) #endif -#define BYTE_IN_LONG(x,b) ((x>>(8*_ENDIAN(b)))&0xff) - -/*-----------------------------------------------------------------*/ -/* printIvalType - generates ival for int/char */ -/*-----------------------------------------------------------------*/ -void print_idataType (FILE *of, symbol *sym, sym_link * type, initList * ilist) -{ - value *val; - unsigned long ulval; - - //fprintf(stderr, "%s\n",__FUNCTION__); - - /* if initList is deep */ - if (ilist->type == INIT_DEEP) - ilist = ilist->init.deep; - - if (!IS_AGGREGATE(sym->type) && getNelements(type, ilist)>1) { - werror (W_EXCESS_INITIALIZERS, "scalar", sym->name, sym->lineDef); - } - - if (!(val = list2val (ilist))) { - // assuming a warning has been thrown - val=constVal("0"); - } - - if (val->type != type) { - val = valCastLiteral(type, floatFromVal(val)); - } - - if(val) - ulval = (unsigned long) floatFromVal (val); - else - ulval =0; - - switch (getSize (type)) { - case 1: - fprintf(of, "%s\tdata\t0x%02x\n", sym->name, (unsigned char)BYTE_IN_LONG(ulval, 0)); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,0)))); - break; - - case 2: -// fprintf(of, "%s\tdw\t0x%04x\n", sym->name, (unsigned int)(BYTE_IN_LONG(ulval, 0) -// + (BYTE_IN_LONG(ulval, 1) << 8))); - fprintf(of, "%s\tdata\t0x%02x,0x%02x\n", sym->name, (unsigned char)BYTE_IN_LONG(ulval, 0), - (unsigned char)(BYTE_IN_LONG(ulval, 1) << 8)); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,0)))); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,1)))); - break; - - case 4: - fprintf(of, "%s\tdw\t0x%04x,0x%04x\n", sym->name, (unsigned int)(BYTE_IN_LONG(ulval, 0) - + (BYTE_IN_LONG(ulval, 1) << 8)), - (unsigned)(BYTE_IN_LONG(ulval, 2) - + (BYTE_IN_LONG(ulval, 3) << 8))); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,0)))); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,1)))); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,2)))); -// pic16_addpCode2pBlock(pb,pic16_newpCode(POC_RETLW,pic16_newpCodeOpLit(BYTE_IN_LONG(ulval,3)))); - break; - } -} - - - -/*-----------------------------------------------------------------*/ -/* printIval - generates code for initial value */ -/*-----------------------------------------------------------------*/ -void print_idata(FILE *of, symbol * sym, sym_link * type, initList * ilist) -{ - if (!ilist) - return; - - /* if structure then */ - if (IS_STRUCT (type)) - { - //fprintf(stderr,"%s struct\n",__FUNCTION__); - //printIvalStruct (sym, type, ilist, oFile); - return; - } - - /* if this is a pointer */ - if (IS_PTR (type)) - { - //fprintf(stderr,"%s pointer\n",__FUNCTION__); - //printIvalPtr (sym, type, ilist, oFile); - return; - } - - /* if this is an array */ - if (IS_ARRAY (type)) - { - //fprintf(stderr,"%s array\n",__FUNCTION__); -// printIvalArray (sym, type, ilist, pb); - return; - } - - /* if type is SPECIFIER */ - if (IS_SPEC (type)) - { -// fprintf(stderr,"%s spec\n",__FUNCTION__); - print_idataType(of, sym, type, ilist); - return; - } -} - - -void pic16_dump_idata(FILE *of, set *idataSymSet) -{ - int i; - symbol *ids; - - - i = elementsInSet(idataSymSet); - if(!i)return; - - fprintf(of, "\n\n; Initialised data (idata)\n"); - fprintf(of, "\tidata\n"); - for(ids = setFirstItem(idataSymSet); ids; ids = setNextItem(idataSymSet)) - print_idata(of, ids, ids->type, ids->ival); - -} - /*-----------------------------------------------------------------* * void pic16_list_valid_pics(int ncols, int list_alias) @@ -628,6 +512,8 @@ int checkAddReg(set **set, regs *reg) { regs *tmp; + + if(!reg)return 0; #if DEBUG_CHECK fprintf(stderr, "%s: about to insert REGister: %s ... ", __FUNCTION__, reg->name); #endif @@ -654,6 +540,7 @@ int checkAddSym(set **set, symbol *sym) { symbol *tmp; + if(!sym)return 0; #if DEBUG_CHECK fprintf(stderr, "%s: about to add SYMbol: %s ... ", __FUNCTION__, sym->name); #endif @@ -677,6 +564,33 @@ int checkAddSym(set **set, symbol *sym) return 0; } +int checkSym(set *set, symbol *sym) +{ + symbol *tmp; + + if(!sym)return 0; + +#if DEUG_CHECK + fprintf(stderr, "%s: about to search for SYMbol: %s ... ", __FUNCTION__, sym->name); +#endif + + for(tmp = setFirstItem( set ); tmp; tmp = setNextItem( set )) { + if(!strcmp(tmp->name, sym->name))break; + } + + if(!tmp) { +#if DEBUG_CHECK + fprintf(stderr, "not found\n"); +#endif + return 0; + } + +#if DEBUG_CHECK + fprintf(stderr, "found\n"); +#endif + + return 1; +} /*-----------------------------------------------------------------* * void pic16_groupRegistersInSection - add each register to its * @@ -685,18 +599,54 @@ int checkAddSym(set **set, symbol *sym) void pic16_groupRegistersInSection(set *regset) { regs *reg; + sectSym *ssym; + int docontinue=0; for(reg=setFirstItem(regset); reg; reg = setNextItem(regset)) { -// fprintf(stderr, "%s:%d group registers in section, reg: %s\n", __FILE__, __LINE__, reg->name); +#if 0 + fprintf(stderr, "%s:%d group registers in section, reg: %s (used: %d, %p)\n", + __FILE__, __LINE__, reg->name, reg->wasUsed, reg); +#endif + if((reg->wasUsed + && !(reg->regop && SPEC_EXTR(OP_SYM_ETYPE(reg->regop)))) + ) { + + /* avoid grouping registers that have an initial value, + * they will be added later in idataSymSet */ + if(reg->regop && (OP_SYMBOL(reg->regop)->ival && !OP_SYMBOL(reg->regop)->level)) + continue; + +#if 0 + fprintf(stderr, "%s:%d register %s alias:%d fix:%d ival=%i level=%i code=%i\n", + __FILE__, __LINE__, reg->name, reg->alias, reg->isFixed, + (reg->regop?(OP_SYMBOL(reg->regop)->ival?1:0):-1), + (reg->regop?(OP_SYMBOL(reg->regop)->level):-1), + (reg->regop?(IS_CODE(OP_SYM_ETYPE(reg->regop))):-1) ); +#endif + + docontinue=0; + for(ssym=setFirstItem(sectSyms);ssym;ssym=setNextItem(sectSyms)) { + if(!strcmp(ssym->name, reg->name)) { +// fprintf(stderr, "%s:%d section found %s (%p) with var %s\n", +// __FILE__, __LINE__, ssym->section->name, ssym->section, ssym->name); + if(strcmp(ssym->section->name, "access")) { + addSet(&ssym->section->regsSet, reg); + docontinue=1; + break; + } else { + docontinue=0; + reg->accessBank = 1; + break; + } + } + } - if(reg->wasUsed - && !(reg->regop && SPEC_EXTR(OP_SYM_ETYPE(reg->regop)))) { + if(docontinue)continue; -// fprintf(stderr, "%s:%d register %s alias:%d fix:%d\n", -// __FILE__, __LINE__, reg->name, reg->alias, reg->isFixed); +// fprintf(stderr, "%s:%d reg: %s\n", __FILE__, __LINE__, reg->name); - if(reg->alias) { + if(reg->alias == 0x80) { checkAddReg(&pic16_equ_data, reg); } else if(reg->isFixed) { @@ -705,8 +655,13 @@ void pic16_groupRegistersInSection(set *regset) if(!reg->isFixed) { if(reg->pc_type == PO_GPR_TEMP) checkAddReg(&pic16_int_regs, reg); - else - checkAddReg(&pic16_rel_udata, reg); + else { + if(reg->accessBank) { + if(reg->alias != 0x40) + checkAddReg(&pic16_acs_udata, reg); + } else + checkAddReg(&pic16_rel_udata, reg); + } } } } @@ -724,82 +679,44 @@ void pic16_groupRegistersInSection(set *regset) * This routine will assign a value to that address. * *-----------------------------------------------------------------*/ - -void pic16_assignConfigWordValue(int address, int value) +void pic16_assignConfigWordValue(int address, unsigned int value) { - switch(address) { - case CONFIG1H_WORD_ADDRESS: - config1h_word = value; - break; - case CONFIG2L_WORD_ADDRESS: - config2l_word = value; - break; - case CONFIG2H_WORD_ADDRESS: - config2h_word = value; - break; - case CONFIG3H_WORD_ADDRESS: - config3h_word = value; - break; - case CONFIG4L_WORD_ADDRESS: - config4l_word = value; - break; - case CONFIG5L_WORD_ADDRESS: - config5l_word = value; - break; - case CONFIG5H_WORD_ADDRESS: - config5h_word = value; - break; - case CONFIG6L_WORD_ADDRESS: - config6l_word = value; - break; - case CONFIG6H_WORD_ADDRESS: - config6h_word = value; - break; - case CONFIG7L_WORD_ADDRESS: - config7l_word = value; - break; - case CONFIG7H_WORD_ADDRESS: - config7h_word = value; - break; - } + int i; + + for(i=0;icwInfo.confAddrEnd-pic16->cwInfo.confAddrStart+1;i++) { + if((address == pic16->cwInfo.confAddrStart+i) + && (pic16->cwInfo.crInfo[i].mask != -1)) { - fprintf(stderr,"setting config word to 0x%x\n",value); +#if 0 + fprintf(stderr, "setting location 0x%X to value 0x%x\tmask: 0x%x\ttest: 0x%x\n", + /*address*/ pic16->cwInfo.confAddrStart+i, (~value)&0xff, + pic16->cwInfo.crInfo[i].mask, + (pic16->cwInfo.crInfo[i].mask) & (~value)); +#endif + +#if 0 + if((((pic16->cwInfo.crInfo[i].mask) & (~value))&0xff) != ((~value)&0xff)) { + fprintf(stderr, "%s:%d a wrong value has been given for configuration register 0x%x\n", + __FILE__, __LINE__, address); + return; + } +#endif + pic16->cwInfo.crInfo[i].value = value; + pic16->cwInfo.crInfo[i].emit = 1; + return; + } + } } -/*-----------------------------------------------------------------* - * int pic16_getConfigWord(int address) - * - * Get the current value of the config word. - * - *-----------------------------------------------------------------*/ -int pic16_getConfigWord(int address) +void pic16_assignIdByteValue(int address, char value) { - switch(address) { - case CONFIG1H_WORD_ADDRESS: - return config1h_word; - case CONFIG2L_WORD_ADDRESS: - return config2l_word; - case CONFIG2H_WORD_ADDRESS: - return config2h_word; - case CONFIG3H_WORD_ADDRESS: - return config3h_word; - case CONFIG4L_WORD_ADDRESS: - return config4l_word; - case CONFIG5L_WORD_ADDRESS: - return config5l_word; - case CONFIG5H_WORD_ADDRESS: - return config5h_word; - case CONFIG6L_WORD_ADDRESS: - return config6l_word; - case CONFIG6H_WORD_ADDRESS: - return config6h_word; - case CONFIG7L_WORD_ADDRESS: - return config7l_word; - case CONFIG7H_WORD_ADDRESS: - return config7h_word; - default: - return 0; - } -} + int i; + for(i=0;iidInfo.idAddrEnd-pic16->idInfo.idAddrStart+1;i++) { + if(address == pic16->idInfo.idAddrStart+i) { + pic16->idInfo.irInfo[i].value = value; + pic16->idInfo.irInfo[i].emit = 1; + } + } +}