2cd6e6db63bb8df5f3754a2296412de9aa2c2df9
[fw/sdcc] / src / pic16 / main.c
1 /*-------------------------------------------------------------------------
2
3   main.c - pic16 specific general functions.
4
5    Written by - Scott Dattalo scott@dattalo.com
6    Ported to PIC16 by - Martin Dubuc m.debuc@rogers.com
7     
8    Note that mlh prepended _pic16_ on the static functions.  Makes
9    it easier to set a breakpoint using the debugger.
10
11
12    This program is free software; you can redistribute it and/or modify it
13    under the terms of the GNU General Public License as published by the
14    Free Software Foundation; either version 2, or (at your option) any
15    later version.
16    
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21    
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 -------------------------------------------------------------------------*/
26
27 #include "common.h"
28 #include "main.h"
29 #include "ralloc.h"
30 #include "device.h"
31 #include "SDCCutil.h"
32 #include "glue.h"
33 #include "pcode.h"
34 //#include "gen.h"
35
36
37 static char _defaultRules[] =
38 {
39 #include "peeph.rul"
40 };
41
42 /* list of key words used by pic16 */
43 static char *_pic16_keywords[] =
44 {
45   "at",
46   "bit",
47   "code",
48   "critical",
49   "data",
50   "far",
51   "idata",
52   "interrupt",
53   "near",
54   "pdata",
55   "reentrant",
56   "sfr",
57   "sbit",
58   "using",
59   "xdata",
60   "_data",
61   "_code",
62   "_generic",
63   "_near",
64   "_xdata",
65   "_pdata",
66   "_idata",
67   "_naked",
68   NULL
69 };
70
71
72 pic16_sectioninfo_t pic16_sectioninfo;
73
74
75 extern char *pic16_processor_base_name(void);
76
77 void  pic16_pCodeInitRegisters(void);
78
79 void pic16_assignRegisters (eBBlock ** ebbs, int count);
80
81 static int regParmFlg = 0;      /* determine if we can register a parameter */
82
83 pic16_options_t pic16_options;
84
85 extern set *includeDirsSet;
86 extern set *dataDirsSet;
87 extern set *libFilesSet;
88
89 /* Also defined in gen.h, but the #include is commented out */
90 /* for an unknowned reason. - EEP */
91 void pic16_emitDebuggerSymbol (char *);
92  
93 extern regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias, operand *refop);
94 extern void pic16_emitConfigRegs(FILE *of);
95
96
97
98
99 static void
100 _pic16_init (void)
101 {
102         asm_addTree (&asm_asxxxx_mapping);
103         pic16_pCodeInitRegisters();
104         maxInterrupts = 2;
105
106         /* set pic16 port options to defaults */
107         pic16_options.no_banksel = 0;
108         pic16_options.opt_banksel = 0;
109         pic16_options.omit_configw = 0;
110         pic16_options.omit_ivt = 0;
111         pic16_options.leave_reset = 0;
112         pic16_options.stack_model = 0;                  /* 0 for 'small', 1 for 'large' */
113         pic16_options.ivt_loc = 0x000000;               /* default location of interrupt vectors */
114         pic16_options.nodefaultlibs = 0;                /* link default libraries */
115 }
116
117 static void
118 _pic16_reset_regparm ()
119 {
120   regParmFlg = 0;
121 }
122
123 static int
124 _pic16_regparm (sym_link * l)
125 {
126   /* for this processor it is simple
127      can pass only the first parameter in a register */
128   //if (regParmFlg)
129   //  return 0;
130
131   regParmFlg++;// = 1;
132   return 1;
133 }
134
135
136 int initsfpnt=0;                /* set to 1 if source provides a pragma for stack
137                                  * so glue() later emits code to initialize stack/frame pointers */
138 set *absSymSet;
139
140 static int
141 _process_pragma(const char *sz)
142 {
143   static const char *WHITE = " \t";
144   
145   char  *ptr = strtok((char *)sz, WHITE);
146
147         if (startsWith (ptr, "maxram")) {
148           char *maxRAM = strtok((char *)NULL, WHITE);
149
150                 if (maxRAM != (char *)NULL) {
151                   int maxRAMaddress;
152                   value *maxRAMVal;
153
154                         maxRAMVal = constVal(maxRAM);
155                         maxRAMaddress = (int)floatFromVal(maxRAMVal);
156                         pic16_setMaxRAM(maxRAMaddress);
157                 }
158         }
159         
160         if(startsWith(ptr, "stack")) {
161           char *stackPosS = strtok((char *)NULL, WHITE);
162           value *stackPosVal;
163           regs *reg;
164           symbol *sym;
165
166 //              fprintf(stderr, "Initializing stack pointer to 0x%x\n", (int)floatFromVal(constVal(stackPos)));
167                 stackPosVal = constVal( stackPosS );
168                 stackPos = (unsigned int)floatFromVal( stackPosVal );
169
170                 reg=newReg(REG_SFR, PO_SFR_REGISTER, stackPos, "_stack", 1, 0, NULL);
171                 addSet(&pic16_fix_udata, reg);
172
173                 sym = newSymbol("stack", 0);
174                 sprintf(sym->rname, "_%s", sym->name);
175                 addSet(&publics, sym);
176                 
177                 initsfpnt = 1;          // force glue() to initialize stack/frame pointers */
178
179           return 0;
180         }
181         
182         if(startsWith(ptr, "code")) {
183           char *symname = strtok((char *)NULL, WHITE);
184           char *location = strtok((char *)NULL, WHITE);
185           absSym *absS;
186           value *addr;
187
188                 absS = Safe_calloc(1, sizeof(absSym));
189                 absS->name = Safe_strdup( symname );
190                 addr = constVal( location );
191                 absS->address = (unsigned int)floatFromVal( addr );
192
193                 addSet(&absSymSet, absS);
194                 fprintf(stderr, "%s:%d symbol %s will be placed in location 0x%06x in code memory\n",
195                         __FILE__, __LINE__, symname, absS->address);
196
197           return 0;
198         }         
199
200   return 1;
201 }
202
203 #define REP_UDATA       "--preplace-udata-with="
204
205 #define STACK_MODEL     "--pstack-model="
206 #define OPT_BANKSEL     "--obanksel="
207
208 #define ALT_ASM         "--asm="
209 #define ALT_LINK        "--link="
210
211 #define IVT_LOC         "--ivt-loc"
212 #define NO_DEFLIBS      "--nodefaultlibs"
213
214
215 char *alt_asm=NULL;
216 char *alt_link=NULL;
217
218 extern int pic16_debug_verbose;
219 extern int pic16_ralloc_debug;
220 extern int pic16_pcode_verbose;
221
222 int pic16_enable_peeps=0;
223
224 OPTION pic16_optionsTable[]= {
225         { 0,    NO_DEFLIBS,             &pic16_options.nodefaultlibs,   "do not link default libraries when linking"},
226         { 0,    "--pno-banksel",        &pic16_options.no_banksel,      "do not generate BANKSEL assembler directives"},
227         { 0,    OPT_BANKSEL,            NULL,                           "set banksel optimization level (default=0 no)"},
228         { 0,    "--pomit-config-words", &pic16_options.omit_configw,    "omit the generation of configuration words"},
229         { 0,    "--pomit-ivt",          &pic16_options.omit_ivt,        "omit the generation of the Interrupt Vector Table"},
230         { 0,    "--pleave-reset-vector",&pic16_options.leave_reset,     "when omitting IVT leave RESET vector"},
231         { 0,    STACK_MODEL,    NULL,   "use stack model 'small' (default) or 'large'"},
232
233         { 0,    "--debug-xtra",         &pic16_debug_verbose,   "show more debug info in assembly output"},
234         { 0,    "--debug-ralloc",       &pic16_ralloc_debug,    "dump register allocator debug file *.d"},
235         { 0,    "--pcode-verbose",      &pic16_pcode_verbose,   "dump pcode related info"},
236                 
237         { 0,    REP_UDATA,      NULL,   "Place udata variables at another section: udata_acs, udata_ovr, udata_shr"},
238
239         { 0,    ALT_ASM,        NULL,   "Use alternative assembler"},
240         { 0,    ALT_LINK,       NULL,   "Use alternative linker"},
241
242         { 0,    "--denable-peeps",      &pic16_enable_peeps,    "explicit enable of peepholes"},
243         { 0,    IVT_LOC,        NULL,   "<nnnn> interrupt vector table location"},
244         { 0,    NULL,           NULL,   NULL}
245         };
246
247
248 #define ISOPT(str)      !strncmp(argv[ *i ], str, strlen(str) )
249
250 extern char *getStringArg(const char *,  char **, int *, int);
251 extern int getIntArg(const char *, char **, int *, int);
252
253 static bool
254 _pic16_parseOptions (int *pargc, char **argv, int *i)
255 {
256   int j=0;
257   char *stkmodel;
258   
259   /* TODO: allow port-specific command line options to specify
260    * segment names here.
261    */
262         /* check for arguments that have associated an integer variable */
263         while(pic16_optionsTable[j].pparameter) {
264                 if(ISOPT( pic16_optionsTable[j].longOpt )) {
265                         (*pic16_optionsTable[j].pparameter)++;
266                         return TRUE;
267                 }
268                 j++;
269         }
270
271
272         if(ISOPT(STACK_MODEL)) {
273                 stkmodel = getStringArg(STACK_MODEL, argv, i, *pargc);
274                 if(STRCASECMP(stkmodel, "small"))pic16_options.stack_model = 0;
275                 else if(STRCASECMP(stkmodel, "large"))pic16_options.stack_model = 1;
276                 else {
277                         fprintf(stderr, "Unknown stack model: %s", stkmodel);
278                         exit(-1);
279                 }
280                 return TRUE;
281         }
282
283         if(ISOPT(OPT_BANKSEL)) {
284                 pic16_options.opt_banksel = getIntArg(OPT_BANKSEL, argv, i, *pargc);
285                 return TRUE;
286         }
287
288         if(ISOPT(REP_UDATA)) {
289                 pic16_sectioninfo.at_udata = Safe_strdup(getStringArg(REP_UDATA, argv, i, *pargc));
290                 return TRUE;
291         }
292         
293         if(ISOPT(ALT_ASM)) {
294                 alt_asm = Safe_strdup(getStringArg(ALT_ASM, argv, i, *pargc));
295                 return TRUE;
296         }
297         
298         if(ISOPT(ALT_LINK)) {
299                 alt_link = Safe_strdup(getStringArg(ALT_LINK, argv, i, *pargc));
300                 return TRUE;
301         }
302
303         if(ISOPT(IVT_LOC)) {
304                 pic16_options.ivt_loc = getIntArg(IVT_LOC, argv, i, *pargc);
305                 return TRUE;
306         }
307
308   return FALSE;
309 }
310
311 static void _pic16_initPaths(void)
312 {
313   char pic16incDir[512];
314   char pic16libDir[512];
315   set *pic16incDirsSet;
316   set *pic16libDirsSet;
317   char devlib[512];
318
319         setMainValue("mcu", pic16->name[2] );
320         addSet(&preArgvSet, Safe_strdup("-D{mcu}"));
321
322         sprintf(pic16incDir, "%s%cpic16", INCLUDE_DIR_SUFFIX, DIR_SEPARATOR_CHAR);
323         sprintf(pic16libDir, "%s%cpic16", LIB_DIR_SUFFIX, DIR_SEPARATOR_CHAR);
324
325         if(!options.nostdinc) {
326                 /* setup pic16 include directory */
327                 pic16incDirsSet = appendStrSet(dataDirsSet, NULL, pic16incDir);
328                 mergeSets(&includeDirsSet, pic16incDirsSet);
329         }
330         
331         if(!options.nostdlib) {
332                 /* setup pic16 library directory */
333                 pic16libDirsSet = appendStrSet(dataDirsSet, NULL, pic16libDir);
334                 mergeSets(&libDirsSet, pic16libDirsSet);
335
336                 if(!pic16_options.nodefaultlibs) {
337                         /* now add the library for the device */
338                         sprintf(devlib, "%s.lib", pic16->name[2]);
339                         addSet(&libFilesSet, Safe_strdup(devlib));
340                 }
341         }
342 }
343
344
345 /* forward declarations */
346 extern const char *pic16_linkCmd[];
347 extern const char *pic16_asmCmd[];
348
349 static void
350 _pic16_finaliseOptions (void)
351 {
352         port->mem.default_local_map = data;
353         port->mem.default_globl_map = data;
354
355         /* peepholes are disabled for the time being */
356         options.nopeep = 1;
357
358         /* explicit enable peepholes for testing */
359         if(pic16_enable_peeps)
360                 options.nopeep = 0;
361
362         options.all_callee_saves = 1;           // always callee saves
363 //      options.float_rent = 1;
364 //      options.intlong_rent = 1;
365         
366
367         if(alt_asm && strlen(alt_asm))
368                 pic16_asmCmd[0] = alt_asm;
369         
370         if(alt_link && strlen(alt_link))
371                 pic16_linkCmd[0] = alt_link;
372 }
373
374
375 /* all the rest is commented ifdef'd out */
376 #if 0
377   /* Hack-o-matic: if we are using the flat24 model,
378    * adjust pointer sizes.
379    */
380   if (options.model == MODEL_FLAT24)
381     {
382
383       fprintf (stderr, "*** WARNING: you should use the '-mds390' option "
384                "for DS80C390 support. This code generator is "
385                "badly out of date and probably broken.\n");
386
387       port->s.fptr_size = 3;
388       port->s.gptr_size = 4;
389       port->stack.isr_overhead++;       /* Will save dpx on ISR entry. */
390 #if 1
391       port->stack.call_overhead++;      /* This acounts for the extra byte 
392                                          * of return addres on the stack.
393                                          * but is ugly. There must be a 
394                                          * better way.
395                                          */
396 #endif
397       fReturn = fReturn390;
398       fReturnSize = 5;
399     }
400
401   if (options.model == MODEL_LARGE)
402     {
403       port->mem.default_local_map = xdata;
404       port->mem.default_globl_map = xdata;
405     }
406   else
407     {
408       port->mem.default_local_map = data;
409       port->mem.default_globl_map = data;
410     }
411
412   if (options.stack10bit)
413     {
414       if (options.model != MODEL_FLAT24)
415         {
416           fprintf (stderr,
417                    "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
418           fprintf (stderr, "\t10 bit stack mode disabled.\n");
419           options.stack10bit = 0;
420         }
421       else
422         {
423           /* Fixup the memory map for the stack; it is now in
424            * far space and requires a FPOINTER to access it.
425            */
426           istack->fmap = 1;
427           istack->ptrType = FPOINTER;
428         }
429     }
430 #endif
431
432
433 static void
434 _pic16_setDefaultOptions (void)
435 {
436         /* initialize to defaults section locations, names and addresses */
437         pic16_sectioninfo.at_udata      = "udata";
438
439         /* set pic16 port options to defaults */
440         pic16_options.no_banksel = 0;
441         pic16_options.opt_banksel = 0;
442         pic16_options.omit_configw = 0;
443         pic16_options.omit_ivt = 0;
444         pic16_options.leave_reset = 0;
445         pic16_options.stack_model = 0;                  /* 0 for 'small', 1 for 'large' */
446         pic16_options.ivt_loc = 0x000000;
447         pic16_options.nodefaultlibs = 0;
448 }
449
450 static const char *
451 _pic16_getRegName (struct regs *reg)
452 {
453   if (reg)
454     return reg->name;
455   return "err";
456 }
457
458
459 #if 1
460 static  char *_pic16_mangleFunctionName(char *sz)
461 {
462 //      fprintf(stderr, "mangled function name: %s\n", sz);
463
464   return sz;
465 }
466 #endif
467
468
469 static void
470 _pic16_genAssemblerPreamble (FILE * of)
471 {
472   char *name = pic16_processor_base_name();
473
474         if(!name) {
475                 name = "p18f452";
476                 fprintf(stderr,"WARNING: No Pic has been selected, defaulting to %s\n",name);
477         }
478
479         fprintf (of, "\tlist\tp=%s\n",&name[1]);
480
481         if(!pic16_options.omit_configw) {
482                 pic16_emitConfigRegs(of);
483 #if 0           
484                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300001, pic16_getConfigWord(0x300001));
485                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300002, pic16_getConfigWord(0x300002));
486                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300003, pic16_getConfigWord(0x300003));
487                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300005, pic16_getConfigWord(0x300005));
488                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300006, pic16_getConfigWord(0x300006));
489                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300008, pic16_getConfigWord(0x300008));
490                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x300009, pic16_getConfigWord(0x300009));
491                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x30000a, pic16_getConfigWord(0x30000a));
492                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x30000b, pic16_getConfigWord(0x30000b));
493                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x30000c, pic16_getConfigWord(0x30000c));
494                 fprintf (of, "\t__config 0x%x,0x%hhx\n", 0x30000d, pic16_getConfigWord(0x30000d));
495 #endif
496         }
497         
498   fprintf (of, "\tradix dec\n");
499 }
500
501 /* Generate interrupt vector table. */
502 static int
503 _pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
504 {
505 #if 1
506         /* PIC18F family has only two interrupts, the high and the low
507          * priority interrupts, which reside at 0x0008 and 0x0018 respectively - VR */
508
509         if((!pic16_options.omit_ivt) || (pic16_options.omit_ivt && pic16_options.leave_reset)) {
510                 fprintf(of, "; RESET vector\n");
511                 fprintf(of, "\tgoto\t__sdcc_gsinit_startup\n");
512         }
513         
514         if(!pic16_options.omit_ivt) {
515                 fprintf(of, "\tres 4\n");
516
517
518                 fprintf(of, "; High priority interrupt vector 0x0008\n");
519                 if(interrupts[1]) {
520                         fprintf(of, "\tgoto\t%s\n", interrupts[1]->rname);
521                         fprintf(of, "\tres\t12\n"); 
522                 } else {
523                         fprintf(of, "\tretfie\n");
524                         fprintf(of, "\tres\t14\n");
525                 }
526
527                 fprintf(of, "; Low priority interrupt vector 0x0018\n");
528                 if(interrupts[2]) {
529                         fprintf(of, "\tgoto\t%s\n", interrupts[2]->rname);
530                 } else {
531                         fprintf(of, "\tretfie\n");
532                 }
533         }
534 #endif
535   return TRUE;
536 }
537
538 /* return True if the port can handle the type,
539  * False to convert it to function call */
540 static bool _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
541 {
542 //      fprintf(stderr,"checking for native mult for %c (size: %d)\n", ic->op, getSize(OP_SYMBOL(IC_RESULT(ic))->type));
543
544 #if 1
545         /* multiplication is fixed */
546         /* support mul for char/int/long */
547         if((getSize(OP_SYMBOL(IC_LEFT(ic))->type ) <= 4)
548                 && (ic->op == '*'))return TRUE;
549 #endif
550
551 #if 0
552         /* support div for char/int/long */
553         if((getSize(OP_SYMBOL(IC_LEFT(ic))->type ) <= 0)
554                 && (ic->op == '/'))return TRUE;
555 #endif
556         
557   return FALSE;
558 }
559
560
561 #if 0
562 /* Do CSE estimation */
563 static bool cseCostEstimation (iCode *ic, iCode *pdic)
564 {
565 //    operand *result = IC_RESULT(ic);
566 //    sym_link *result_type = operandType(result);
567
568
569         /* VR -- this is an adhoc. Put here after conversation
570          * with Erik Epetrich */
571
572         if(ic->op == '<'
573                 || ic->op == '>'
574                 || ic->op == EQ_OP) {
575
576                 fprintf(stderr, "%d %s\n", __LINE__, __FUNCTION__);
577           return 0;
578         }
579
580 #if 0
581     /* if it is a pointer then return ok for now */
582     if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
583
584     /* if bitwise | add & subtract then no since mcs51 is pretty good at it
585        so we will cse only if they are local (i.e. both ic & pdic belong to
586        the same basic block */
587     if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
588         /* then if they are the same Basic block then ok */
589         if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
590         else return 0;
591     }
592 #endif
593
594     /* for others it is cheaper to do the cse */
595     return 1;
596 }
597 #endif
598
599
600 /* Indicate which extended bit operations this port supports */
601 static bool
602 hasExtBitOp (int op, int size)
603 {
604   if (op == RRC
605       || op == RLC
606       /* || op == GETHBIT */ /* GETHBIT doesn't look complete for PIC */
607      )
608     return TRUE;
609   else
610     return FALSE;
611 }
612
613 /* Indicate the expense of an access to an output storage class */
614 static int
615 oclsExpense (struct memmap *oclass)
616 {
617   /* The IN_FARSPACE test is compatible with historical behaviour, */
618   /* but I don't think it is applicable to PIC. If so, please feel */
619   /* free to remove this test -- EEP */
620   if (IN_FARSPACE(oclass))
621     return 1;
622     
623   return 0;
624 }
625
626 /** $1 is always the basename.
627     $2 is always the output file.
628     $3 -L path and -l libraries
629     $l is the list of extra options that should be there somewhere...
630     MUST be terminated with a NULL.
631 */
632 const char *pic16_linkCmd[] =
633 {
634   "gplink", "$3", "\"$1.o\"", "-o \"$2\"", "$l", NULL
635 };
636
637
638
639 /** $1 is always the basename.
640     $2 is always the output file.
641     $3 varies (nothing currently)
642     $l is the list of extra options that should be there somewhere...
643     MUST be terminated with a NULL.
644 */
645 const char *pic16_asmCmd[] =
646 {
647   "gpasm", "$l", "$3", "-c", "\"$1.asm\"", "-o \"$2\"", NULL
648
649 };
650
651 /* Globals */
652 PORT pic16_port =
653 {
654   TARGET_ID_PIC16,
655   "pic16",
656   "MCU PIC16",                  /* Target name */
657   "p18f452",                    /* Processor */
658   {
659     pic16glue,
660     TRUE,                       /* Emit glue around main */
661     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
662     MODEL_SMALL
663   },
664   {
665     pic16_asmCmd,               /* assembler command and arguments */
666     NULL,                       /* alternate macro based form */
667     "-g",                       /* arguments for debug mode */
668     NULL,                       /* arguments for normal mode */
669     0,                          /* print externs as global */
670     ".asm",                     /* assembler file extension */
671     NULL                        /* no do_assemble function */
672   },
673   {
674     pic16_linkCmd,              /* linker command and arguments */
675     NULL,                       /* alternate macro based form */
676     NULL,                       /* no do_link function */
677     ".o",                       /* extension for object files */
678     0                           /* no need for linker file */
679   },
680   {
681     _defaultRules
682   },
683   {
684         /* Sizes */
685     1,          /* char */
686     2,          /* short */
687     2,          /* int */
688     4,          /* long */
689     2,          /* ptr */
690     3,          /* fptr, far pointers (see Microchip) */
691     2,          /* gptr */
692     1,          /* bit */
693     4,          /* float */
694     4           /* max */
695   },
696   {
697     "XSEG    (XDATA)",          // xstack
698     "STACK   (DATA)",           // istack
699     "CSEG    (CODE)",           // code
700     "DSEG    (DATA)",           // data
701     "ISEG    (DATA)",           // idata
702     "XSEG    (XDATA)",          // xdata
703     "BSEG    (BIT)",            // bit
704     "RSEG    (DATA)",           // reg
705     "GSINIT  (CODE)",           // static
706     "OSEG    (OVR,DATA)",       // overlay
707     "GSFINAL (CODE)",           // post static
708     "HOME        (CODE)",       // home
709     NULL,                       // xidata
710     NULL,                       // xinit
711     NULL,                       // default location for auto vars
712     NULL,                       // default location for global vars
713     1                           // code is read only 1=yes
714   },
715   {
716     NULL,               /* genExtraAreaDeclaration */
717     NULL                /* genExatrAreaLinkOptions */
718   },
719   {
720         /* stack related information */
721     -1,                 /* -1 stack grows downwards, +1 upwards */
722     1,                  /* extra overhead when calling between banks */
723     4,                  /* extra overhead when the function is an ISR */
724     1,                  /* extra overhead for a function call */
725     1,                  /* re-entrant space */
726     0                   /* 'banked' call overhead, mild overlap with bank_overhead */
727   },
728     /* pic16 has an 8 bit mul */
729   {
730      0, -1
731   },
732   {
733     pic16_emitDebuggerSymbol
734   },
735   "_",
736   _pic16_init,
737   _pic16_parseOptions,
738   pic16_optionsTable,
739   _pic16_initPaths,
740   _pic16_finaliseOptions,
741   _pic16_setDefaultOptions,
742   pic16_assignRegisters,
743   _pic16_getRegName,
744   _pic16_keywords,
745   _pic16_genAssemblerPreamble,
746   NULL,                         /* no genAssemblerEnd */
747   _pic16_genIVT,
748   NULL, // _pic16_genXINIT
749   NULL,                         /* genInitStartup */
750   _pic16_reset_regparm,
751   _pic16_regparm,
752   _process_pragma,                              /* process a pragma */
753   _pic16_mangleFunctionName,                            /* mangles function name */
754   _hasNativeMulFor,
755   hasExtBitOp,                  /* hasExtBitOp */
756   oclsExpense,                  /* oclsExpense */
757   FALSE,                        
758   TRUE,                         /* little endian */
759   0,                            /* leave lt */
760   0,                            /* leave gt */
761   1,                            /* transform <= to ! > */
762   1,                            /* transform >= to ! < */
763   1,                            /* transform != to !(a == b) */
764   0,                            /* leave == */
765   FALSE,                        /* No array initializer support. */
766   0,    //cseCostEstimation,            /* !!!no CSE cost estimation yet */
767   NULL,                         /* no builtin functions */
768   GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
769   1,                            /* reset labelKey to 1 */
770   1,                            /* globals & local static allowed */
771   PORT_MAGIC
772 };