From 495053bd77d8a3381f6bba09bf6ad24c8298150f Mon Sep 17 00:00:00 2001 From: vrokas Date: Wed, 26 Nov 2003 16:32:29 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3029 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 15 ++++ src/SDCCmain.c | 6 +- src/pic16/device.c | 173 ++++++++++++++++++++++++++++++++++++++++----- src/pic16/device.h | 4 +- src/pic16/gen.c | 1 - src/pic16/glue.c | 2 +- src/pic16/main.c | 24 ++++--- src/pic16/ralloc.c | 16 +++-- 8 files changed, 199 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9968daa..82c46439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-11-26 Vangelis Rokas + + * src/pic16/main.c (_pic16_genIVT): fixed interrupt vector table + * src/pic16/main.c (_pic16_genAssemblerPreamble): re-enabled the + output of __config directives, since gpasm now supports them + * src/pic16/main.c (_pic16_finaliseOptions): define MCU + pre-processor macro, i.e. -DMCU=p18f452 + * src/pic16/ralloc.c: renamed packRegisters to pic16_packRegisters, + and modified to handle 'cast' icode similarly to '=' icode + * src/pic16/device.h (typedef struct PIC_device): added field + 'extMIface' to indicate that chip has external memory interface + * src/pic16/device.c: added chips 18F248, 18F258, 18F448, 18F458, + 18F6520, 18F6620, 18F6680, 18F6720, 18F8520, 18F8620, 18F8680, + 18F8720 + 2003-11-26 Erik Petrich * src/SDCC.y (pointer): fixed bug #846006 diff --git a/src/SDCCmain.c b/src/SDCCmain.c index b3974b9f..00e648de 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -289,12 +289,12 @@ static PORT *_ports[] = #if !OPT_DISABLE_DS390 &ds390_port, #endif -#if !OPT_DISABLE_PIC - &pic_port, -#endif #if !OPT_DISABLE_PIC16 &pic16_port, #endif +#if !OPT_DISABLE_PIC + &pic_port, +#endif #if !OPT_DISABLE_TININative &tininative_port, #endif diff --git a/src/pic16/device.c b/src/pic16/device.c index cecd52be..23b9e81a 100644 --- a/src/pic16/device.c +++ b/src/pic16/device.c @@ -20,6 +20,15 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -------------------------------------------------------------------------*/ + +/* + VR - Began writing code to make PIC16 C source files independent from + the header file (created by the inc2h.pl) + + - adding maximum RAM memory into PIC_Device structure + +*/ + #include #include "common.h" // Include everything in the SDCC src directory @@ -38,42 +47,164 @@ static PIC_device Pics[] = { { - {"p18f242", "18f242", "pic18f242", "f242"}, - (memRange *)NULL, - (memRange *)NULL, + {"p18f242", "18f242", "pic18f242", "f242"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x300, // bank mask + 0x300, // RAMsize + 0 + }, + + { + {"p18f252", "18f252", "pic18f252", "f252"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x600, // bank mask + 0x600, // RAMsize + 0 + }, + + { + {"p18f442", "18f442", "pic18f442", "f442"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x300, // bank mask + 0x300, // RAMsize + 0 + }, + + { + {"p18f452", "18f452", "pic18f452", "f452"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x600, // bank mask + 0x600, // RAMsize + 0 + }, + + { + {"p18f248", "18f248", "pic18f248", "f248"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x300, // bank mask + 0x300, // RAMsize + 0 + }, + + { + {"p18f258", "18f258", "pic18f258", "f258"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x600, // bank mask + 0x600, // RAMsize + 0 + }, + + { + {"p18f448", "18f448", "pic18f448", "f448"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map 0, - 0x300, + 0x300, // bank mask + 0x300, // RAMsize + 0 }, { - {"p18f252", "18f252", "pic18f252", "f252"}, - (memRange *)NULL, - (memRange *)NULL, + {"p18f458", "18f458", "pic18f458", "f458"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map 0, - 0x600, + 0x600, // bank mask + 0x600, // RAMsize + 0 }, { - {"p18f442", "18f442", "pic18f442", "f442"}, - (memRange *)NULL, - (memRange *)NULL, + {"p18f6520", "18f6520", "pic18f6520", "f6520"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map 0, - 0x300, + 0x800, // bank mask + 0x800, // RAMsize + 1 }, { - {"p18f452", "18f452", "pic18f452", "f452"}, - (memRange *)NULL, - (memRange *)NULL, + {"p18f6620", "18f6620", "pic18f6620", "f6620"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0xf00, // bank mask + 0xf00, // RAMsize + 1 + }, + { + {"p18f6680", "18f6680", "pic18f6680", "f6680"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0xc00, // bank mask + 0xc00, // RAMsize + 1 + }, + { + {"p18f6720", "18f6720", "pic18f6720", "f6720"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0xf00, // bank mask + 0xf00, // RAMsize + 1 + }, + { + {"p18f8520", "18f8520", "pic18f8520", "f8520"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0x800, // bank mask + 0x800, // RAMsize + 1 + }, + { + {"p18f8620", "18f8620", "pic18f8620", "f8620"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0xf00, // bank mask + 0xf00, // RAMsize + 1 + }, + { + {"p18f8680", "18f8680", "pic18f8680", "f8680"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map + 0, + 0xc00, // bank mask + 0x800, // RAMsize + 1 + }, + { + {"p18f8720", "18f8720", "pic18f8720", "f8720"}, // aliases + (memRange *)NULL, // ram memory map + (memRange *)NULL, // sfr memory map 0, - 0x600, + 0xf00, // bank mask + 0xf00, // RAMsize + 1 }, }; static int num_of_supported_PICS = sizeof(Pics)/sizeof(PIC_device); -#define DEFAULT_PIC "f452" +#define DEFAULT_PIC "452" static PIC_device *pic=NULL; @@ -137,6 +268,9 @@ void pic16_addMemRange(memRange *r, int type) return; } +// fprintf(stderr, "%s: adding memory range from 0x%x to 0x%x type= %d\n", +// __FUNCTION__, r->start_address, r->end_address, type); + do { for (i=r->start_address; i<= r->end_address; i++) { if ((i|alias) <= pic->maxRAMaddress) { @@ -525,16 +659,17 @@ static int assignRegister(regs *reg, int start_address) { int i; - //fprintf(stderr,"%s - %s start_address = 0x%03x\n",__FUNCTION__,reg->name, start_address); +// fprintf(stderr,"%s - %s start_address = 0x%03x\t(max=0x%03x)\n",__FUNCTION__,reg->name, start_address, pic->maxRAMaddress); if(reg->isFixed) { if (validAddress(reg->address,reg->size)) { - //fprintf(stderr,"%s - %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address); +// fprintf(stderr,"fixed %s - %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address); mapRegister(reg); return reg->address; } if( isSFR(reg->address)) { +// fprintf(stderr,"sfr %s - %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address); mapRegister(reg); return reg->address; } diff --git a/src/pic16/device.h b/src/pic16/device.h index b1803175..ec12138b 100644 --- a/src/pic16/device.h +++ b/src/pic16/device.h @@ -90,8 +90,8 @@ typedef struct PIC_device { int maxRAMaddress; /* maximum value for a data address */ int bankMask; /* Bitmask that is ANDed with address to extract banking bits */ - // int hasAliasedRAM:1; /* True if there are bank independent registers */ - + int RAMsize; /* size of Data RAM - VR 031120 */ + int extMIface; /* device has external memory interface */ } PIC_device; /* Given a pointer to a register, this macro returns the bank that it is in */ diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 367ae284..c0587054 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -61,7 +61,6 @@ static int optimized_for_speed = 0; hack hack */ -int options_no_movff = 1; /* max_key keeps track of the largest label number used in a function. This is then used to adjust the label offset diff --git a/src/pic16/glue.c b/src/pic16/glue.c index ba58923f..0c3c7f3d 100644 --- a/src/pic16/glue.c +++ b/src/pic16/glue.c @@ -809,7 +809,7 @@ pic16glue () pic16_InlinepCode(); - pic16_AnalyzepCode('*'); + pic16_AnalyzepCode('*'); pic16_pcode_test(); diff --git a/src/pic16/main.c b/src/pic16/main.c index e1c6f24c..772b6d41 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -66,6 +66,9 @@ static char *_pic16_keywords[] = NULL }; + +extern char *pic16_processor_base_name(void); + void pic16_pCodeInitRegisters(void); void pic16_assignRegisters (eBBlock ** ebbs, int count); @@ -174,9 +177,15 @@ _pic16_parseOptions (int *pargc, char **argv, int *i) static void _pic16_finaliseOptions (void) { + port->mem.default_local_map = data; + port->mem.default_globl_map = data; - port->mem.default_local_map = data; - port->mem.default_globl_map = data; + setMainValue("mcu", pic16_processor_base_name() ); + addSet(&preArgvSet, Safe_strdup("-DMCU={mcu}")); +} + + +/* all the rest is commented ifdef'd out */ #if 0 /* Hack-o-matic: if we are using the flat24 model, * adjust pointer sizes. @@ -232,7 +241,7 @@ _pic16_finaliseOptions (void) } } #endif -} + static void _pic16_setDefaultOptions (void) @@ -247,7 +256,6 @@ _pic16_getRegName (struct regs *reg) return "err"; } -extern char *pic16_processor_base_name(void); static void _pic16_genAssemblerPreamble (FILE * of) @@ -263,7 +271,6 @@ _pic16_genAssemblerPreamble (FILE * of) fprintf (of, "\tlist\tp=%s\n",&name[1]); fprintf (of, "\tinclude \"%s.inc\"\n",name); -#if 0 fprintf (of, "\t__config _CONFIG1H,0x%x\n",pic16_getConfigWord(0x300001)); fprintf (of, "\t__config _CONFIG2L,0x%x\n",pic16_getConfigWord(0x300002)); fprintf (of, "\t__config _CONFIG2H,0x%x\n",pic16_getConfigWord(0x300003)); @@ -275,7 +282,6 @@ _pic16_genAssemblerPreamble (FILE * of) fprintf (of, "\t__config _CONFIG6H,0x%x\n",pic16_getConfigWord(0x30000b)); fprintf (of, "\t__config _CONFIG7L,0x%x\n",pic16_getConfigWord(0x30000c)); fprintf (of, "\t__config _CONFIG7H,0x%x\n",pic16_getConfigWord(0x30000d)); -#endif fprintf (of, "\tradix dec\n"); } @@ -300,16 +306,16 @@ _pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) fprintf(of, "; RESET vector\n"); fprintf(of, "\tgoto\t__sdcc_gsinit_startup\n"); - fprintf(of, "\tres 6\n"); + fprintf(of, "\tres 4\n"); fprintf(of, "; High priority interrupt vector 0x0008\n"); if(interrupts[1]) { fprintf(of, "\tgoto\t%s\n", interrupts[1]->rname); - fprintf(of, "\tres\t8\n"); + fprintf(of, "\tres\t12\n"); } else { fprintf(of, "\tretfie\n"); - fprintf(of, "\tres\t8\n"); + fprintf(of, "\tres\t14\n"); } fprintf(of, "; Low priority interrupt vector 0x0018\n"); diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index 41de32e8..726bb68d 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -3451,12 +3451,13 @@ static void isData(sym_link *sl) } } -/*-----------------------------------------------------------------*/ -/* packRegisters - does some transformations to reduce register */ -/* pressure */ -/*-----------------------------------------------------------------*/ +/*--------------------------------------------------------------------*/ +/* pic16_packRegisters - does some transformations to reduce */ +/* register pressure */ +/* */ +/*--------------------------------------------------------------------*/ static void -packRegisters (eBBlock * ebp) +pic16_packRegisters (eBBlock * ebp) { iCode *ic; int change = 0; @@ -3475,7 +3476,8 @@ packRegisters (eBBlock * ebp) { /* find assignment of the form TrueSym := iTempNN:1 */ - if (ic->op == '=' && !POINTER_SET (ic)) + /* see BUGLOG0001 for workaround with the CAST - VR */ + if ((ic->op == '=' || ic->op == CAST) && !POINTER_SET (ic)) change += packRegsForAssign (ic, ebp); /* debug stuff */ if (ic->op == '=') @@ -3825,7 +3827,7 @@ pic16_assignRegisters (eBBlock ** ebbs, int count) /* change assignments this will remove some live ranges reducing some register pressure */ for (i = 0; i < count; i++) - packRegisters (ebbs[i]); + pic16_packRegisters (ebbs[i]); { regs *reg; -- 2.30.2