From 3a32de81ff00b39434dd9a96b6de5be03a3f45cb Mon Sep 17 00:00:00 2001 From: sdattalo Date: Sun, 18 May 2003 18:54:44 +0000 Subject: [PATCH] PIC16 - Applied patch from Vangelis Rokas. Many fixes for the PIC16 port. #ifdef's were added to disable some port dependent options. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2626 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 39 ++++++++++++++++++++++++++++ configure | 20 +++++++++++++++ configure.in | 11 ++++++++ sdccconf_in.h | 1 + src/SDCCmain.c | 62 +++++++++++++++++++++++++++++++++++++-------- src/SDCCpeeph.c | 10 ++++---- src/SDCCset.c | 16 ++++++++++++ src/SDCCset.h | 1 + src/SDCCsymt.c | 4 +-- src/clean.mk | 2 +- src/pic/glue.c | 10 ++++---- src/pic/main.c | 2 +- src/pic/ralloc.c | 3 ++- src/pic16/Makefile | 2 ++ src/pic16/device.c | 5 ++-- src/pic16/gen.c | 22 ++++++++++++++-- src/pic16/glue.c | 6 ++++- src/pic16/main.c | 10 +++++--- src/pic16/pcode.c | 2 +- src/pic16/peeph.def | 32 +++++++++++++++-------- src/port.h | 7 +++++ 21 files changed, 222 insertions(+), 45 deletions(-) create mode 100644 src/pic16/Makefile diff --git a/ChangeLog b/ChangeLog index 50ed88ce..f7036eaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2003-05-18 Vangelis Rokas (vrokas@otenet.gr) + + * configure.in: configure for pic16 port, + added --disable-pic16-port + * sdccconf_in.h: added macro OPT_DISABLE_PIC16 + * src/SDCCmain.c: linkOptions is changed to set *, + added if/endif conditional macros to remove options help + messages from optionsTable when a port is not configured, added + support for the PIc16 port in the ports table, when executing + the compiler with no port specified on command line, a default + port is selected with the new macro DEFAULT_PORT which is + defined in port.h, in setDefaultOptions() linkOptions is removed + from initialization assignment, since now it is a set, + parseCmdLine uses setParseWithComma for linkOptions, in + linkEdit() linkOptions are accessed with new function indexSet() + which returns the i'th item of a set variable. See SDCCset.c, in + linkEdit() when calling buildCmdLine(), added linkOptions as + last argument. Now users can pass arguments to gplink via the + -Wl option, main() uses pic16glue() to glue up pic16 programs + * src/SDCCpeeph.c: various changes to support pic16 + * src/SDCCset.c: added function void *indexSet(set *, int) to + return the i'th item of the set + * src/SDCCset.h: added function prototype for indexSet() + * src/SDCCsymt.c: in checkSClass(), added support for PIC16 + * src/clean.mk: added pic16 in CLEANALLPORTS variable + * src/port.h: added TARGET_ID_PIC16,TARGET_IS_PIC16 macro, + added macro DEFAULT_PORT + * src/pic/main.c: corrected arguments of gplnk in _linkCmd + * src/pic16/gen.c: bug fix in genCpl(), now the correct code is + generated + * src/pic16/glue.c: commented out some error producing lines + * src/pic16/main.c: __config directives are commented out to stop + gpasm complaining and test the linkage with gplink, _linkCmd and + _asmCmd changed to be more gplink and gpasm friendly + * src/pic16/peeph.def: peep rule 3 is commented out, since it + produced an error when parsed, peep rule 12 is added to utilize + movff, but it is commented out since the pCode does not support + yet a command with 2 address arguments + 2003-05-18 * src/ds390/gen.c (genArrayInit): removed obsolete and buggy ARRAYINIT diff --git a/configure b/configure index 0f949774..a0b6e55a 100755 --- a/configure +++ b/configure @@ -875,6 +875,7 @@ Optional Features: --disable-ds390-port Excludes the DS390 port --disable-ds400-port Excludes the DS400 port --disable-pic-port Excludes the PIC port + --disable-pic16-port Excludes the PIC16 port --disable-xa51-port Excludes the XA51 port --disable-ucsim Disables configuring and building of ucsim --disable-device-lib-build @@ -6582,6 +6583,25 @@ _ACEOF fi +# Check whether --enable-pic16-port or --disable-pic16-port was given. +if test "${enable_pic16_port+set}" = set; then + enableval="$enable_pic16_port" + +fi; +echo pic16 >>ports.all +if test "$enable_pic16_port" = "no"; then + cat >>confdefs.h <<_ACEOF +#define OPT_DISABLE_PIC16 1 +_ACEOF + +else + echo pic16 >>ports.build + cat >>confdefs.h <<_ACEOF +#define OPT_DISABLE_PIC16 0 +_ACEOF + +fi + # Check whether --enable-xa51-port or --disable-xa51-port was given. if test "${enable_xa51_port+set}" = set; then enableval="$enable_xa51_port" diff --git a/configure.in b/configure.in index b6626262..4cb736b3 100755 --- a/configure.in +++ b/configure.in @@ -577,6 +577,17 @@ else AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 0) fi +AC_ARG_ENABLE(pic16-port, + AC_HELP_STRING([--disable-pic16-port], + [Excludes the PIC port])) +echo pic16 >>ports.all +if test "$enable_pic16_port" = "no"; then + AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC16, 1) +else + echo pic16 >>ports.build + AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC16, 0) +fi + AC_ARG_ENABLE(xa51-port, AC_HELP_STRING([--disable-xa51-port], [Excludes the XA51 port])) diff --git a/sdccconf_in.h b/sdccconf_in.h index 04c60ac0..a34379dd 100644 --- a/sdccconf_in.h +++ b/sdccconf_in.h @@ -66,6 +66,7 @@ #undef OPT_DISABLE_DS400 #undef OPT_DISABLE_TININative #undef OPT_DISABLE_PIC +#undef OPT_DISABLE_PIC16 #undef OPT_DISABLE_XA51 #undef OPT_ENABLE_LIBGC diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 83d4db79..b8978bb3 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -66,7 +66,7 @@ struct options options; int preProcOnly = 0; int noAssemble = 0; set *asmOptions = NULL; /* set of assembler options */ -char *linkOptions[128]; +set /*char*/ *linkOptions=NULL; /* set of linker options [128]; */ char *libFiles[128]; int nlibFiles = 0; char *libPaths[128]; @@ -140,10 +140,14 @@ optionsTable[] = { { 0, OPTION_LARGE_MODEL, NULL, "external data space is used" }, { 0, OPTION_MEDIUM_MODEL, NULL, "not supported" }, { 0, OPTION_SMALL_MODEL, NULL, "internal data space is used (default)" }, +#if !OPT_DISABLE_DS390 { 0, OPTION_FLAT24_MODEL, NULL, "use the flat24 model for the ds390 (default)" }, +#endif { 0, "--stack-auto", &options.stackAuto, "Stack automatic variables" }, +#if !OPT_DISABLE_DS390 { 0, OPTION_STACK_8BIT, NULL, "use the 8bit stack for the ds390 (not supported yet)" }, { 0, "--stack-10bit", &options.stack10bit, "use the 10bit stack for ds390 (default)" }, +#endif { 0, "--xstack", &options.useXstack, "Use external stack" }, { 0, OPTION_NO_GCSE, NULL, "Disable the GCSE optimisation" }, { 0, OPTION_NO_LABEL_OPT, NULL, "Disable label optimisation" }, @@ -198,11 +202,19 @@ optionsTable[] = { { 0, "--profile", &options.profile, "On supported ports, generate extra profiling information" }, { 0, "--fommit-frame-pointer", &options.ommitFramePtr, "Leave out the frame pointer." }, { 0, "--all-callee-saves", &options.all_callee_saves, "callee will always save registers used" }, +#if !OPT_DISABLE_DS390 { 0, "--use-accelerator", &options.useAccelerator,"generate code for DS390 Arithmetic Accelerator"}, +#endif { 0, "--stack-probe", &options.stack_probe,"insert call to function __stack_probe at each function prologue"}, +#if !OPT_DISABLE_TININative { 0, "--tini-libid", NULL," LibraryID used in -mTININative"}, +#endif +#if !OPT_DISABLE_DS390 { 0, "--protect-sp-update", &options.protect_sp_update,"DS390 - will disable interrupts during ESP:SP updates"}, +#endif +#if !OPT_DISABLE_DS390 || !OPT_DISABLE_MCS51 { 0, "--parms-in-bank1", &options.parms_in_bank1,"MCS51/DS390 - use Bank1 for parameter passing"}, +#endif { 0, OPTION_NO_XINIT_OPT, &options.noXinitOpt, "don't memcpy initialized xram from code"}, { 0, OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"}, { 0, OPTION_ICODE_IN_ASM, &options.iCodeInAsm, "include i-code as comments in the asm file"}, @@ -268,6 +280,9 @@ static PORT *_ports[] = #if !OPT_DISABLE_PIC &pic_port, #endif +#if !OPT_DISABLE_PIC16 + &pic16_port, +#endif #if !OPT_DISABLE_TININative &tininative_port, #endif @@ -284,6 +299,9 @@ static PORT *_ports[] = #if !OPT_DISABLE_PIC extern void picglue (); #endif +#if !OPT_DISABLE_PIC16 +extern void pic16glue(); +#endif /** Sets the port to the one given by the command line option. @param The name minus the option (eg 'mcs51') @@ -347,8 +365,15 @@ _findPort (int argc, char **argv) } argv++; } + /* Use the first in the list */ - port = _ports[0]; +#if defined(DEFAULT_PORT) + /* VR - 13/5/2003 DEFAULT_PORT is defined in port.h */ + port = &DEFAULT_PORT; +#else + port = _ports[0]; +#endif + } /* search through the command line options for the processor */ @@ -500,7 +525,7 @@ setDefaultOptions () int i; for (i = 0; i < 128; i++) - preArgv[i] = linkOptions[i] = relFiles[i] = libFiles[i] = libPaths[i] = NULL; + preArgv[i] = /*linkOptions[i] = */relFiles[i] = libFiles[i] = libPaths[i] = NULL; /* first the options part */ options.stack_loc = 0; /* stack pointer initialised to 0 */ @@ -1096,7 +1121,7 @@ parseCmdLine (int argc, char **argv) /* linker options */ else if (argv[i][2] == 'l') { - parseWithComma(linkOptions, getStringArg("-Wl", argv, &i, argc)); + setParseWithComma(&linkOptions, getStringArg("-Wl", argv, &i, argc)); } /* assembler options */ else if (argv[i][2] == 'a') @@ -1340,9 +1365,9 @@ linkEdit (char **envp) } /* add the extra linker options */ - for (i = 0; linkOptions[i]; i++) - fprintf (lnkfile, "%s\n", linkOptions[i]); - + for (i = 0; ilinker.cmd) { char buffer2[PATH_MAX]; - buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, NULL); - buildCmdLine2 (buffer, buffer2, sizeof(buffer)); + + /* VR 030517 - gplink needs linker options to set the linker script,*/ + buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, linkOptions); + + buildCmdLine2 (buffer, buffer2, sizeof(buffer)); } else { buildCmdLine2 (buffer, port->linker.mcmd, sizeof(buffer)); } +// if (options.verbose)fprintf(stderr, "linker command line: %s\n", buffer); + system_ret = my_system (buffer); /* TODO: most linker don't have a -o parameter */ /* -o option overrides default name? */ @@ -1978,8 +2008,18 @@ main (int argc, char **argv, char **envp) #if !OPT_DISABLE_PIC picglue (); #endif - } - else { + + } else + if(TARGET_IS_PIC16) { + /* PIC16 port misc improvements Vangelis Rokas - 6-May-2003 + Generate .asm files for gpasm (just like PIC target) but use + pic16glue() + */ + +#if !OPT_DISABLE_PIC16 + pic16glue(); +#endif + } else { glue (); } diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index e052e3ea..9e7d672e 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -52,7 +52,7 @@ static bool matchLine (char *, char *, hTab **); #define FBYNAME(x) int x (hTab *vars, lineNode *currPl, lineNode *endPl, \ lineNode *head, const char *cmdLine) -#if !OPT_DISABLE_PIC +#if !OPT_DISABLE_PIC || !OPT_DISABLE_PIC16 void peepRules2pCode(peepRule *); #endif @@ -1433,9 +1433,9 @@ peepHole (lineNode ** pls) lineNode *mtail = NULL; bool restart; -#if !OPT_DISABLE_PIC +#if !OPT_DISABLE_PIC || !OPT_DISABLE_PIC16 /* The PIC port uses a different peep hole optimizer based on "pCode" */ - if (TARGET_IS_PIC) + if (TARGET_IS_PIC || TARGET_IS_PIC16) return; #endif @@ -1574,11 +1574,11 @@ initPeepHole () } -#if !OPT_DISABLE_PIC +#if !OPT_DISABLE_PIC || !OPT_DISABLE_PIC16 /* Convert the peep rules into pcode. NOTE: this is only support in the PIC port (at the moment) */ - if (TARGET_IS_PIC) { + if (TARGET_IS_PIC || TARGET_IS_PIC16) { peepRules2pCode(rootRules); } #endif diff --git a/src/SDCCset.c b/src/SDCCset.c index 5014303f..f8bab736 100644 --- a/src/SDCCset.c +++ b/src/SDCCset.c @@ -402,6 +402,22 @@ elementsInSet (set * s) return count; } +/*-----------------------------------------------------------------*/ +/* indexSet - returns the i'th item in set */ +/*-----------------------------------------------------------------*/ +void *indexSet(set * s, int index) +{ + set *loop=s; + + while(loop && index) { + index--; + loop = loop->next; + } + + return (loop->item); +} + + /*-----------------------------------------------------------------*/ /* reverseSet - reverse the order of the items of a set */ /*-----------------------------------------------------------------*/ diff --git a/src/SDCCset.h b/src/SDCCset.h index 93da8dda..344007cf 100644 --- a/src/SDCCset.h +++ b/src/SDCCset.h @@ -67,6 +67,7 @@ set *setFromSet (set *); int isSetsEqual (set *, set *); set *subtractFromSet (set *, set *, int); int elementsInSet (set *); +void *indexSet(set *, int); set *intersectSetsWith (set *, set *, int (*cFunc) (void *, void *), int); int isSetsEqualWith (set *, set *, int (*cFunc) (void *, void *)); void *peekSet (set *); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 80ccfc5a..be673e50 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1144,9 +1144,9 @@ checkSClass (symbol * sym, int isProto) /* if absolute address given then it mark it as volatile -- except in the PIC port */ -#if !OPT_DISABLE_PIC +#if !OPT_DISABLE_PIC || !OPT_DISABLE_PIC16 /* The PIC port uses a different peep hole optimizer based on "pCode" */ - if (!TARGET_IS_PIC) + if (!TARGET_IS_PIC && !TARGET_IS_PIC16) #endif if (IS_ABSOLUTE (sym->etype)) diff --git a/src/clean.mk b/src/clean.mk index 074e9cf0..d308c9b7 100644 --- a/src/clean.mk +++ b/src/clean.mk @@ -1,4 +1,4 @@ -CLEANALLPORTS = avr ds390 izt mcs51 pic z80 xa51 +CLEANALLPORTS = avr ds390 izt mcs51 pic pic16 z80 xa51 PRJDIR = .. # Deleting all files created by building the program diff --git a/src/pic/glue.c b/src/pic/glue.c index 8a94ee42..7699fbad 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -789,11 +789,6 @@ picglue () cdbStructBlock (0); vFile = tempfile(); - /* PENDING: this isnt the best place but it will do */ - if (port->general.glue_up_main) { - /* create the interrupt vector table */ - pic14createInterruptVect (vFile); - } addSetHead(&tmpfileSet,vFile); @@ -802,6 +797,11 @@ picglue () /* do the overlay segments */ pic14emitOverlay(ovrFile); + /* PENDING: this isnt the best place but it will do */ + if (port->general.glue_up_main) { + /* create the interrupt vector table */ + pic14createInterruptVect (vFile); + } AnalyzepCode('*'); diff --git a/src/pic/main.c b/src/pic/main.c index 7b91caa2..78cfda60 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -327,7 +327,7 @@ _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right) */ static const char *_linkCmd[] = { - "gplink", "-nf", "\"$1\"", NULL + "gplink", "", "\"$1.o\"", NULL }; static const char *_asmCmd[] = diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 1614e6c9..b1a37641 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -977,7 +977,8 @@ void packBits(set *bregs) breg->address >>= 3; if(!bitfield) { - sprintf (buffer, "fbitfield%02x", breg->address); + //sprintf (buffer, "fbitfield%02x", breg->address); + sprintf (buffer, "0x%02x", breg->address); //fprintf(stderr,"new bit field\n"); bitfield = newReg(REG_SFR, PO_GPR_BIT,breg->address,buffer,1,0); bitfield->isBitField = 1; diff --git a/src/pic16/Makefile b/src/pic16/Makefile new file mode 100644 index 00000000..3b856364 --- /dev/null +++ b/src/pic16/Makefile @@ -0,0 +1,2 @@ +# Make all in this directory +include ../port.mk diff --git a/src/pic16/device.c b/src/pic16/device.c index 3b33b564..f5861d81 100644 --- a/src/pic16/device.c +++ b/src/pic16/device.c @@ -458,7 +458,7 @@ static int validAddress(int address, int reg_size) fprintf(stderr, "missing \"#pragma maxram\" setting\n"); return 0; } - // fprintf(stderr, "validAddress: Checking 0x%04x\n",address); +// fprintf(stderr, "validAddress: Checking 0x%04x (max=0x%04x) (reg_size = %d)\n",address, pic->maxRAMaddress, reg_size); if(address > pic->maxRAMaddress) return 0; @@ -522,7 +522,7 @@ 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\n",__FUNCTION__,reg->name, start_address); if(reg->isFixed) { if (validAddress(reg->address,reg->size)) { @@ -548,6 +548,7 @@ static int assignRegister(regs *reg, int start_address) for (i=start_address; i<=pic->maxRAMaddress; i++) { if (validAddress(i,reg->size)) { + fprintf(stderr, "found valid address = 0x%04x\n", i); reg->address = i; mapRegister(reg); return i; diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 422ad251..d6f5eddf 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -264,6 +264,8 @@ void pic16_emitcode (char *inst,char *fmt, ...) lineCurr->isInline = _G.inLine; lineCurr->isDebug = _G.debugLine; +// VR fprintf(stderr, "lb = <%s>\n", lbp); + if(pic16_debug_verbose) pic16_addpCode2pBlock(pb,pic16_newpCodeCharP(lb)); @@ -1919,10 +1921,22 @@ static void genCpl (iCode *ic) size = AOP_SIZE(IC_RESULT(ic)); while (size--) { +/* char *l = pic16_aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE); MOVA(l); pic16_emitcode("cpl","a"); pic16_aopPut(AOP(IC_RESULT(ic)),"a",offset++); +*/ + if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) { + DEBUGpic16_emitcode("; ", "same registers"); + pic16_emitpcode(POC_COMF, pic16_popGet(AOP(IC_LEFT(ic)), offset)); + } else { + DEBUGpic16_emitcode(";", "not sames registers!"); + pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),offset)); + pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),offset)); + } + offset++; + } @@ -9909,6 +9923,7 @@ void genpic16Code (iCode *lic) pb = pic16_newpCodeChain(GcurMemmap,0,pic16_newpCodeCharP("; Starting pCode block")); pic16_addpBlock(pb); +#if 0 /* if debug information required */ if (options.debug && currFunc) { if (currFunc) { @@ -9924,11 +9939,13 @@ void genpic16Code (iCode *lic) _G.debugLine = 0; } } - +#endif for (ic = lic ; ic ; ic = ic->next ) { - DEBUGpic16_emitcode(";ic",""); +// fprintf(stderr, "; VR = %c %x\n", ic->op, ic->op); +// DEBUGpic16_emitcode("; VR", ""); + DEBUGpic16_emitcode(";ic ", "\t%c 0x%x",ic->op, ic->op); if ( cln != ic->lineno ) { if ( options.debug ) { _G.debugLine = 1; @@ -10160,3 +10177,4 @@ void genpic16Code (iCode *lic) return; } + diff --git a/src/pic16/glue.c b/src/pic16/glue.c index 7e7d1c7e..f9728d6c 100644 --- a/src/pic16/glue.c +++ b/src/pic16/glue.c @@ -444,6 +444,7 @@ pic16emitStaticSeg (memmap * map) if (!IS_STATIC (sym->etype)) addSetHead (&publics, sym); +#if 0 /* print extra debug info if required */ if (options.debug || sym->level == 0) { @@ -466,6 +467,7 @@ pic16emitStaticSeg (memmap * map) fprintf (code->oFile, "%s_%d_%d", sym->name, sym->level, sym->block); } +#endif /* if it has an absolute address */ if (SPEC_ABSA (sym->etype)) @@ -677,6 +679,7 @@ pic16emitOverlay (FILE * afile) if (IS_FUNC (sym->type)) continue; +#if 0 /* print extra debug info if required */ if (options.debug || sym->level == 0) { @@ -696,6 +699,7 @@ pic16emitOverlay (FILE * afile) (sym->localof ? sym->localof->name : "-null-")); fprintf (afile, "%s_%d_%d", sym->name, sym->level, sym->block); } +#endif /* if is has an absolute address then generate an equate for this no need to allocate space */ @@ -774,7 +778,7 @@ pic16glue () /* print the global struct definitions */ if (options.debug) - cdbStructBlock (0,cdbFile); + cdbStructBlock (0); //,cdbFile); vFile = tempfile(); /* PENDING: this isnt the best place but it will do */ diff --git a/src/pic16/main.c b/src/pic16/main.c index 8b3f3ae9..57cf4e3f 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -17,7 +17,7 @@ static char _defaultRules[] = #include "peeph.rul" }; -/* list of key words used by msc51 */ +/* list of key words used by pic16 */ static char *_pic16_keywords[] = { "at", @@ -240,6 +240,8 @@ _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)); @@ -251,6 +253,8 @@ _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"); } @@ -336,7 +340,7 @@ _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right) */ static const char *_linkCmd[] = { - "aslink", "-nf", "$1", NULL + "gplink", "\"$1.o\"", "-o $1", "$l", NULL }; /* Sigh. This really is not good. For now, I recommend: @@ -345,7 +349,7 @@ static const char *_linkCmd[] = */ static const char *_asmCmd[] = { - "gpasm", "-c -I /usr/local/share/gpasm/header", "$1.asm", NULL + "gpasm", "-c -I /usr/local/share/gputils/header", "\"$1.asm\"", NULL }; diff --git a/src/pic16/pcode.c b/src/pic16/pcode.c index b0a6645a..5c84c367 100644 --- a/src/pic16/pcode.c +++ b/src/pic16/pcode.c @@ -79,7 +79,7 @@ static pBlock *pb_dead_pcodes = NULL; /* Hardcoded flags to change the behavior of the PIC port */ static int peepOptimizing = 1; /* run the peephole optimizer if nonzero */ static int functionInlining = 1; /* inline functions if nonzero */ -int pic16_debug_verbose = 0; /* Set true to inundate .asm file */ +int pic16_debug_verbose = 1; /* Set true to inundate .asm file */ static int GpCodeSequenceNumber = 1; static int GpcFlowSeq = 1; diff --git a/src/pic16/peeph.def b/src/pic16/peeph.def index c0e7b81c..1d8a2750 100644 --- a/src/pic16/peeph.def +++ b/src/pic16/peeph.def @@ -105,6 +105,7 @@ // Also, notice that this snippet is not valid if // it follows another skip + replace restart { _NOTBITSKIP_ %1 _BITSKIP_ %2 @@ -161,16 +162,16 @@ replace restart { } if NZ // peep 3 -replace restart { - decf %1,f - movf %1,w - btfss _STATUS,z - goto %2 -} by { - ; peep 3 - decf/mov/skpz to decfsz - decfsz %1,f - goto %2 -} +//replace restart { +/ decf %1,f +/// movf %1,w +// btfss _STATUS,z +// goto %2 +//} by { +// ; peep 3 - decf/mov/skpz to decfsz +// decfsz %1,f +// goto %2 +//} replace restart { @@ -283,3 +284,14 @@ replace restart { ; peep 11 - Removed redundant move movf %1,w } + + +// From: Vangelis Rokas (vrokas@otenet.gr) + +//replace { +// movf %1,W +// movwf %2 +//} by { +// ; peep 12 - Use movff to move source to dest +// movff %1, %2 +//} diff --git a/src/port.h b/src/port.h index cc747fd7..63500d49 100644 --- a/src/port.h +++ b/src/port.h @@ -14,6 +14,7 @@ #define TARGET_ID_AVR 4 #define TARGET_ID_DS390 5 #define TARGET_ID_PIC 6 +#define TARGET_ID_PIC16 7 #define TARGET_ID_XA51 9 #define TARGET_ID_DS400 10 @@ -27,6 +28,7 @@ #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390) #define TARGET_IS_DS400 (port->id==TARGET_ID_DS400) #define TARGET_IS_PIC (port->id==TARGET_ID_PIC) +#define TARGET_IS_PIC16 (port->id==TARGET_ID_PIC16) #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51) #define MAX_BUILTIN_ARGS 16 @@ -280,6 +282,9 @@ extern PORT ds390_port; #if !OPT_DISABLE_PIC extern PORT pic_port; #endif +#if !OPT_DISABLE_PIC16 +extern PORT pic16_port; +#endif #if !OPT_DISABLE_TININative extern PORT tininative_port; #endif @@ -290,4 +295,6 @@ extern PORT xa51_port; extern PORT ds400_port; #endif +#define DEFAULT_PORT pic16_port + #endif /* PORT_INCLUDE*/ -- 2.47.2