db-statements in order to allow for arrays of pointers in code
sections to be placed without interspersed 0-padding, fixes
bug #
1256215
* (emitStatistics): fixed division by zero for pic18f1220
* src/pic16/pcode.c: buffer (up to) 12 DB directives to allow for
unpadded writing of 8-bit, 16-bit, 24-bit and 32-bit values
* (pic16_emitDS): respect DB_ITEMS_PER_LINE
* (pic16_pCodeConstString): keep track of already emitted string
literals to prevent "duplicate definitions of symbol _str_NR"
* src/pic16/ralloc.c (pic16_allocRegByName): removed not so helpful
debug message
* device/lib/Makefile.in: ignore failing PIC16 library builds
* device/lib/pic16/Makefile: do not build if gputils are missing
* device/lib/pic16/Makefile.common.in: do not enforce MAKEFLAGS=-s
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3840
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2005-08-12 Raphael Neider <rneider AT web.de>
+
+ * src/pic16/glue.c (pic16_print(G)PointerType): do not flush
+ db-statements in order to allow for arrays of pointers in code
+ sections to be placed without interspersed 0-padding, fixes
+ bug #1256215
+ * (emitStatistics): fixed division by zero for pic18f1220
+ * src/pic16/pcode.c: buffer (up to) 12 DB directives to allow for
+ unpadded writing of 8-bit, 16-bit, 24-bit and 32-bit values
+ * (pic16_emitDS): respect DB_ITEMS_PER_LINE
+ * (pic16_pCodeConstString): keep track of already emitted string
+ literals to prevent "duplicate definitions of symbol _str_NR"
+ * src/pic16/ralloc.c (pic16_allocRegByName): removed not so helpful
+ debug message
+ * device/lib/Makefile.in: ignore failing PIC16 library builds
+ * device/lib/pic16/Makefile: do not build if gputils are missing
+ * device/lib/pic16/Makefile.common.in: do not enforce MAKEFLAGS=-s
+
2005-08-10 Raphael Neider <rneider AT web.de>
* device/lib/Makefile.in: fixed copying pic16 libraries (broken by
fi
port-specific-objects-pic16:
- if [ -d $(PORT) ]; then \
+ -if [ -d $(PORT) ]; then \
mkdir -p $(PORT)/bin; \
$(MAKE) -C $(PORT); \
cp -f $(PORT)/bin/*.o $(PORT)/bin/*.lib $(PORTDIR); \
include $(topsrcdir)/Makefile.common
+ifeq (:,$(findstring :,$(LD) $(AS) $(LIB)))
+
+all % :
+ @echo "gputils not found -- PIC16 library not built!"
+
+else
+
SUBDIRS = debug libc libdev libio libm libsdcc startup
builddir = build
installdir = bin
clean-intermediate : recurse
include $(topsrcdir)/Makefile.rules
+
+endif
#Q ?= # be verbose
Q ?= @ # be quiet
# be really quiet (suppress "Entering/Leaving directory...")
-MAKEFLAGS := $(filter-out -s,$(MAKEFLAGS)) -s
+#MAKEFLAGS := $(filter-out -s,$(MAKEFLAGS)) -s
#################################################
### compiler switches
void pic16_printPointerType (const char *name, char ptype, void *p)
{
_pic16_printPointerType (name, ptype, p);
- pic16_flushDB(ptype, p);
+ //pic16_flushDB(ptype, p); /* breaks char* const arr[] = {&c, &c, &c}; */
}
/*-----------------------------------------------------------------*/
assert( 0 );
}
- pic16_flushDB(ptype, p);
+ //pic16_flushDB(ptype, p); /* might break char* const arr[] = {...}; */
}
pic16_addpCode2pBlock(pb,pcf);
pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(sym->rname,-1));
-// fprintf(stderr, "%s:%d [1] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
+ //fprintf(stderr, "%s:%d [1] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
pic16_printIval(sym, sym->type, sym->ival, 'p', (void *)pb);
pic16_flushDB('p', (void *)pb);
didcode++;
}
-
-// fprintf(stderr, "%s:%d [2] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(sym->rname,-1));
+ //fprintf(stderr, "%s:%d [2] generating init for label: %s\n", __FILE__, __LINE__, sym->rname);
pic16_printIval(sym, sym->type, sym->ival, 'p', (void *)pb);
pic16_flushDB('p', (void *)pb);
noAlloc--;
void emitStatistics(FILE *asmFile)
{
- unsigned long isize, udsize;
+ unsigned long isize, udsize, ramsize;
statistics.isize = pic16_countInstructions();
isize = (statistics.isize >= 0) ? statistics.isize : 0;
udsize = (statistics.udsize >= 0) ? statistics.udsize : 0;
+ ramsize = pic16 ? pic16->RAMsize : 0x200;
+ ramsize -= 256; /* ignore access bank and SFRs */
+ if (ramsize == 0) ramsize = 64; /* prevent division by zero (below) */
fprintf (asmFile, "\n\n; Statistics:\n");
- fprintf (asmFile, "; code size:\t%5ld (0x%04lx) bytes (%3.2f%%)\n; \t%5ld (0x%04lx) words\n",
- isize, isize, (isize*100.0)/(128 << 10),
+ fprintf (asmFile, "; code size:\t%5ld (0x%04lx) bytes (%5.2f%%)\n; \t%5ld (0x%04lx) words\n",
+ isize, isize, (isize*100.0)/(128UL << 10),
isize>>1, isize>>1);
- fprintf (asmFile, "; udata size:\t%5ld (0x%04lx) bytes (%3.2f%%)\n",
- udsize, udsize, (udsize*100.0) / ((pic16 ? pic16->RAMsize : 0x200) -256));
+ fprintf (asmFile, "; udata size:\t%5ld (0x%04lx) bytes (%5.2f%%)\n",
+ udsize, udsize, (udsize*100.0) / (1.0 * ramsize));
fprintf (asmFile, "; access size:\t%5ld (0x%04lx) bytes\n",
statistics.intsize, statistics.intsize);
return pcop;
}
-#define DB_ITEMS_PER_LINE 8
+/* This is a multiple of two as gpasm pads DB directives to even length,
+ * thus the data would be interleaved with \0 bytes...
+ * This is a multiple of three in order to have arrays of 3-byte pointers
+ * continuously in memory (without 0-padding at the lines' end).
+ * This is rather 12 than 6 in order not to split up 4-byte data types
+ * in arrays right in the middle of a 4-byte word. */
+#define DB_ITEMS_PER_LINE 12
typedef struct DBdata
{
int count;
- char buffer[256];
+ char buffer[512];
} DBdata;
struct DBdata DBd;
// fprintf(stderr, "%s:%d DBbuffer: '%s'\n", __FILE__, __LINE__, DBd.buffer);
DBd.count++; //=strlen(s);
- if (DBd.count>=16)
+ if (DBd.count>=DB_ITEMS_PER_LINE)
pic16_flushDB(ptype, p);
}
void pic16_pCodeConstString(char *name, char *value)
{
pBlock *pb;
-
- // fprintf(stderr, " %s %s %s\n",__FUNCTION__,name,value);
+ char *item;
+ static set *emittedSymbols = NULL;
if(!name || !value)
return;
+ /* keep track of emitted symbols to avoid multiple definition of str_<nr> */
+ if (emittedSymbols) {
+ /* scan set for name */
+ for (item = setFirstItem (emittedSymbols); item; item = setNextItem (emittedSymbols))
+ {
+ if (!strcmp (item,name)) {
+ //fprintf (stderr, "%s already emitted\n", name);
+ return;
+ } // if
+ } // for
+ } // if
+ addSet (&emittedSymbols, Safe_strdup (name));
+
+ //fprintf(stderr, " %s %s %s\n",__FUNCTION__,name,value);
+
pb = pic16_newpCodeChain(NULL, 'P',pic16_newpCodeCharP("; Starting pCode block"));
pic16_addpBlock(pb);
* a new one and put it in the hash table AND in the
* dynDirectRegNames set */
- fprintf (stderr,"%s:%d symbol name %s\tregop= %p\n", __FUNCTION__, __LINE__, name, op);
+ //fprintf (stderr,"%s:%d symbol name %s\tregop= %p\n", __FUNCTION__, __LINE__, name, op);
reg = newReg(REG_GPR, PO_DIR, rDirectIdx++, name,size,0, op);