+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 <johan@balder>
* src/ds390/gen.c (genArrayInit): removed obsolete and buggy ARRAYINIT
--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
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"
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]))
#undef OPT_DISABLE_DS400
#undef OPT_DISABLE_TININative
#undef OPT_DISABLE_PIC
+#undef OPT_DISABLE_PIC16
#undef OPT_DISABLE_XA51
#undef OPT_ENABLE_LIBGC
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];
{ 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" },
{ 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,"<nnnn> 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"},
#if !OPT_DISABLE_PIC
&pic_port,
#endif
+#if !OPT_DISABLE_PIC16
+ &pic16_port,
+#endif
#if !OPT_DISABLE_TININative
&tininative_port,
#endif
#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')
}
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 */
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 */
/* 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')
}
/* add the extra linker options */
- for (i = 0; linkOptions[i]; i++)
- fprintf (lnkfile, "%s\n", linkOptions[i]);
-
+ for (i = 0; i<elementsInSet(linkOptions); i++)
+ fprintf (lnkfile, "%s\n", (char *)indexSet(linkOptions, i));
+
/* other library paths if specified */
for (i = 0; i < nlibPaths; i++)
fprintf (lnkfile, "-k %s\n", libPaths[i]);
if (port->linker.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? */
#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 ();
}
#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
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
}
-#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
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 */
/*-----------------------------------------------------------------*/
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 *);
/* 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))
-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
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);
/* 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('*');
*/
static const char *_linkCmd[] =
{
- "gplink", "-nf", "\"$1\"", NULL
+ "gplink", "", "\"$1.o\"", NULL
};
static const char *_asmCmd[] =
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;
--- /dev/null
+# Make all in this directory
+include ../port.mk
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;
{
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)) {
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;
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));
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++;
+
}
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) {
_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;
return;
}
+
if (!IS_STATIC (sym->etype))
addSetHead (&publics, sym);
+#if 0
/* print extra debug info if required */
if (options.debug || sym->level == 0)
{
fprintf (code->oFile, "%s_%d_%d", sym->name, sym->level, sym->block);
}
+#endif
/* if it has an absolute address */
if (SPEC_ABSA (sym->etype))
if (IS_FUNC (sym->type))
continue;
+#if 0
/* print extra debug info if required */
if (options.debug || sym->level == 0)
{
(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 */
/* 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 */
#include "peeph.rul"
};
-/* list of key words used by msc51 */
+/* list of key words used by pic16 */
static char *_pic16_keywords[] =
{
"at",
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));
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");
}
*/
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:
*/
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
};
/* 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;
// Also, notice that this snippet is not valid if
// it follows another skip
+
replace restart {
_NOTBITSKIP_ %1
_BITSKIP_ %2
} 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 {
; 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
+//}
#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
#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
#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
extern PORT ds400_port;
#endif
+#define DEFAULT_PORT pic16_port
+
#endif /* PORT_INCLUDE*/