+void pic16_printIvalBitFields(symbol **sym, initList **ilist, char ptype, void *p)
+{
+ value *val ;
+ symbol *lsym = *sym;
+ initList *lilist = *ilist ;
+ unsigned long ival = 0;
+ int size =0;
+
+
+#if DEBUG_PRINTIVAL
+ fprintf(stderr, "%s\n",__FUNCTION__);
+#endif
+
+
+ do {
+ unsigned long i;
+ val = list2val(lilist);
+ if (size) {
+ if (SPEC_BLEN(lsym->etype) > 8) {
+ size += ((SPEC_BLEN (lsym->etype) / 8) +
+ (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
+ }
+ } else {
+ size = ((SPEC_BLEN (lsym->etype) / 8) +
+ (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
+ }
+ i = (unsigned long)floatFromVal(val);
+ i <<= SPEC_BSTR (lsym->etype);
+ ival |= i;
+ if (! ( lsym->next &&
+ (IS_BITFIELD(lsym->next->type)) &&
+ (SPEC_BSTR(lsym->next->etype)))) break;
+ lsym = lsym->next;
+ lilist = lilist->next;
+ } while (1);
+ switch (size) {
+ case 1:
+ pic16_emitDB(BYTE_IN_LONG(ival, 0), ptype, p);
+ break;
+
+ case 2:
+ pic16_emitDB(BYTE_IN_LONG(ival, 0), ptype, p);
+ pic16_emitDB(BYTE_IN_LONG(ival, 1), ptype, p);
+ break;
+
+ case 4: /* EEP: why is this db and not dw? */
+ pic16_emitDB(BYTE_IN_LONG(ival, 0), ptype, p);
+ pic16_emitDB(BYTE_IN_LONG(ival, 1), ptype, p);
+ pic16_emitDB(BYTE_IN_LONG(ival, 2), ptype, p);
+ pic16_emitDB(BYTE_IN_LONG(ival, 3), ptype, p);
+ break;
+ default:
+ /* VR - only 1,2,4 size long can be handled???? Why? */
+ fprintf(stderr, "%s:%d: unhandled case. Contact author.\n", __FILE__, __LINE__);
+ assert(0);
+ }
+ *sym = lsym;
+ *ilist = lilist;
+}
+
+
+/*-----------------------------------------------------------------*/
+/* printIvalStruct - generates initial value for structures */
+/*-----------------------------------------------------------------*/
+void pic16_printIvalStruct (symbol * sym, sym_link * type,
+ initList * ilist, char ptype, void *p)
+{
+ symbol *sflds;
+ initList *iloop = NULL;
+
+
+#if DEBUG_PRINTIVAL
+ fprintf(stderr, "%s\n",__FUNCTION__);
+#endif
+
+ sflds = SPEC_STRUCT (type)->fields;
+
+ if (ilist) {
+ if (ilist->type != INIT_DEEP) {
+ werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
+ return;
+ }
+
+ iloop = ilist->init.deep;
+ }
+
+ for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) {
+// fprintf(stderr, "%s:%d sflds: %p\tiloop = %p\n", __FILE__, __LINE__, sflds, iloop);
+ if (IS_BITFIELD(sflds->type)) {
+ pic16_printIvalBitFields(&sflds, &iloop, ptype, p);
+ } else {
+ pic16_printIval (sym, sflds->type, iloop, ptype, p);
+ }
+ }
+ if (iloop) {
+ werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
+ }
+ return;
+}
+
+/*--------------------------------------------------------------------------*/
+/* pic16_printIvalCharPtr - generates initial values for character pointers */
+/*--------------------------------------------------------------------------*/
+int pic16_printIvalCharPtr (symbol * sym, sym_link * type, value * val, char ptype, void *p)
+{
+ int size = 0;
+
+ /* PENDING: this is _very_ mcs51 specific, including a magic
+ number...
+ It's also endin specific.
+
+ VR - Attempting to port this function to pic16 port - 8-Jun-2004
+ */
+
+
+#if DEBUG_PRINTIVAL
+ fprintf(stderr, "%s\n",__FUNCTION__);
+#endif
+
+ size = getSize (type);
+
+ if (val->name && strlen (val->name))
+ {
+ if (size == 1) /* This appears to be Z80 specific?? */
+ {
+ pic16_emitDS(val->name, ptype, p);
+ }
+ else if (size == 2)
+ {
+ pic16_printPointerType (val->name, ptype, p);
+ }
+ else if (size == 3)
+ {
+ int type;
+ if (IS_PTR (val->type)) {
+ type = DCL_TYPE (val->type);
+ } else {
+ type = PTR_TYPE (SPEC_OCLS (val->etype));
+ }
+ if (val->sym && val->sym->isstrlit) {
+ // this is a literal string
+ type=CPOINTER;
+ }
+ pic16_printGPointerType(val->name, sym->name, type, type, ptype, p);
+ }
+ else
+ {
+ fprintf (stderr, "*** internal error: unknown size in "
+ "printIvalCharPtr.\n");
+ assert(0);
+ }
+ }
+ else
+ {
+ // these are literals assigned to pointers
+ switch (size)
+ {
+ case 1:
+ pic16_emitDB(pic16aopLiteral(val, 0), ptype, p);
+ break;
+ case 2:
+ pic16_emitDB(pic16aopLiteral(val, 0), ptype, p);
+ pic16_emitDB(pic16aopLiteral(val, 1), ptype, p);
+ break;
+ case 3:
+ pic16_emitDB(pic16aopLiteral(val, 0), ptype, p);
+ pic16_emitDB(pic16aopLiteral(val, 1), ptype, p);
+ pic16_emitDB(pic16aopLiteral(val, 2), ptype, p);
+ break;
+
+ default:
+ assert (0);
+ }
+ }
+
+ if (val->sym && val->sym->isstrlit) { // && !isinSet(statsg->syms, val->sym)) {
+ if(ptype == 'p' && !isinSet(statsg->syms, val->sym))addSet (&statsg->syms, val->sym);
+ else if(ptype == 'f' /*&& !isinSet(rel_idataSymSet, val->sym)*/)addSet(&rel_idataSymSet, val->sym);
+ }
+
+ return 1;
+}
+
+/*-----------------------------------------------------------------------*/
+/* pic16_printIvalFuncPtr - generate initial value for function pointers */
+/*-----------------------------------------------------------------------*/
+void pic16_printIvalFuncPtr (sym_link * type, initList * ilist, char ptype, void *p)