2 pic14 specific general functions.
4 Note that mlh prepended _pic14_ on the static functions. Makes
5 it easier to set a breakpoint using the debugger.
14 static char _defaultRules[] =
19 /* list of key words used by msc51 */
20 static char *_pic14_keywords[] =
47 void pCodeInitRegisters(void);
49 void pic14_assignRegisters (eBBlock ** ebbs, int count);
51 static int regParmFlg = 0; /* determine if we can register a parameter */
56 asm_addTree (&asm_asxxxx_mapping);
61 _pic14_reset_regparm ()
67 _pic14_regparm (sym_link * l)
69 /* for this processor it is simple
70 can pass only the first parameter in a register */
79 _pic14_parseOptions (int *pargc, char **argv, int *i)
81 /* TODO: allow port-specific command line options to specify
88 _pic14_finaliseOptions (void)
91 port->mem.default_local_map = data;
92 port->mem.default_globl_map = data;
94 /* Hack-o-matic: if we are using the flat24 model,
95 * adjust pointer sizes.
97 if (options.model == MODEL_FLAT24)
100 fprintf (stderr, "*** WARNING: you should use the '-mds390' option "
101 "for DS80C390 support. This code generator is "
102 "badly out of date and probably broken.\n");
104 port->s.fptr_size = 3;
105 port->s.gptr_size = 4;
106 port->stack.isr_overhead++; /* Will save dpx on ISR entry. */
108 port->stack.call_overhead++; /* This acounts for the extra byte
109 * of return addres on the stack.
110 * but is ugly. There must be a
114 fReturn = fReturn390;
118 if (options.model == MODEL_LARGE)
120 port->mem.default_local_map = xdata;
121 port->mem.default_globl_map = xdata;
125 port->mem.default_local_map = data;
126 port->mem.default_globl_map = data;
129 if (options.stack10bit)
131 if (options.model != MODEL_FLAT24)
134 "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
135 fprintf (stderr, "\t10 bit stack mode disabled.\n");
136 options.stack10bit = 0;
140 /* Fixup the memory map for the stack; it is now in
141 * far space and requires a FPOINTER to access it.
144 istack->ptrType = FPOINTER;
151 _pic14_setDefaultOptions (void)
156 _pic14_getRegName (struct regs *reg)
163 extern char *processor_base_name(void);
166 _pic14_genAssemblerPreamble (FILE * of)
168 char * name = processor_base_name();
173 fprintf(stderr,"WARNING: No Pic has been selected, defaulting to %s\n",name);
176 fprintf (of, "\tlist\tp=%s\n",&name[1]);
177 fprintf (of, "\t__CONFIG 0x%x\n",getConfigWord(0x2007));
178 fprintf (of, "\ninclude \"%s.inc\"\n",name);
181 /* Generate interrupt vector table. */
183 _pic14_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
187 if (options.model != MODEL_FLAT24)
189 /* Let the default code handle it. */
193 fprintf (of, "\t;ajmp\t__sdcc_gsinit_startup\n");
195 /* now for the other interrupts */
196 for (i = 0; i < maxInterrupts; i++)
200 fprintf (of, "\t;ljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
204 fprintf (of, "\t;reti\n\t.ds\t7\n");
212 _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
214 sym_link *test = NULL;
217 fprintf(stderr,"checking for native mult\n");
226 if ( IS_LITERAL (left))
228 fprintf(stderr,"left is lit\n");
230 val = OP_VALUE (IC_LEFT (ic));
232 else if ( IS_LITERAL (right))
234 fprintf(stderr,"right is lit\n");
236 val = OP_VALUE (IC_RIGHT (ic));
240 fprintf(stderr,"oops, neither is lit so no\n");
244 if ( getSize (test) <= 2)
246 fprintf(stderr,"yep\n");
249 fprintf(stderr,"nope\n");
255 /** $1 is always the basename.
256 $2 is always the output file.
258 $l is the list of extra options that should be there somewhere...
259 MUST be terminated with a NULL.
261 static const char *_linkCmd[] =
263 "aslink", "-nf", "$1", NULL
266 /* Sigh. This really is not good. For now, I recommend:
267 * sdcc -S -mpic14 file.c
268 * the -S option does not compile or link
270 static const char *_asmCmd[] =
272 "gpasm", "-c -I /usr/local/share/gpasm/header", "$1.asm", NULL
281 "MCU pic", /* Target name */
282 "p16f877", /* Processor */
284 TRUE, /* Emit glue around main */
285 MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
293 //"-plosgffc", /* Options with debug */
294 //"-plosgff", /* Options without debug */
297 NULL /* no do_assemble function */
309 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
310 1, 2, 2, 4, 1, 2, 2, 1, 4, 4
311 /* TSD - I changed the size of gptr from 3 to 1. However, it should be
312 2 so that we can accomodate the PIC's with 4 register banks (like the
333 1 // code is read only
338 /* pic14 has an 8 bit mul */
346 _pic14_finaliseOptions,
347 _pic14_setDefaultOptions,
348 pic14_assignRegisters,
351 _pic14_genAssemblerPreamble,
352 NULL, /* no genAssemblerEnd */
354 NULL, // _pic14_genXINIT
355 _pic14_reset_regparm,
363 1, /* transform <= to ! > */
364 1, /* transform >= to ! < */
365 1, /* transform != to !(a == b) */
367 FALSE, /* No array initializer support. */
368 0, /* no CSE cost estimation yet */
369 NULL, /* no builtin functions */
370 GPOINTER, /* treat unqualified pointers as "generic" pointers */
371 1, /* reset labelKey to 1 */
372 1, /* globals & local static allowed */