* as/hc08/lkaomf51.c (OutputName): made name unsigned char,
[fw/sdcc] / src / mcs51 / main.c
1 /** @file main.c
2     mcs51 specific general functions.
3
4     Note that mlh prepended _mcs51_ on the static functions.  Makes
5     it easier to set a breakpoint using the debugger.
6 */
7 #include "common.h"
8 #include "main.h"
9 #include "ralloc.h"
10 #include "gen.h"
11 #include "../SDCCutil.h"
12
13 static char _defaultRules[] =
14 {
15 #include "peeph.rul"
16 };
17
18 /* list of key words used by msc51 */
19 static char *_mcs51_keywords[] =
20 {
21   "at",
22   "banked",
23   "bit",
24   "code",
25   "critical",
26   "data",
27   "far",
28   "idata",
29   "interrupt",
30   "near",
31   "pdata",
32   "reentrant",
33   "sfr",
34   "sfr16",
35   "sfr32",
36   "sbit",
37   "using",
38   "xdata",
39   "_data",
40   "_code",
41   "_generic",
42   "_near",
43   "_xdata",
44   "_pdata",
45   "_idata",
46   "_naked",
47   "_overlay",
48   NULL
49 };
50
51
52
53 void mcs51_assignRegisters (ebbIndex *);
54
55 static int regParmFlg = 0;      /* determine if we can register a parameter     */
56 static int regBitParmFlg = 0;   /* determine if we can register a bit parameter */
57
58 static void
59 _mcs51_init (void)
60 {
61   asm_addTree (&asm_asxxxx_mapping);
62 }
63
64 static void
65 _mcs51_reset_regparm (void)
66 {
67   regParmFlg = 0;
68   regBitParmFlg = 0;
69 }
70
71 static int
72 _mcs51_regparm (sym_link * l, bool reentrant)
73 {
74     if (IS_SPEC(l) && (SPEC_NOUN(l) == V_BIT)) {
75         /* bit parameters go to b0 thru b7 */
76         if (reentrant && (regBitParmFlg < 8)) {
77             regBitParmFlg++;
78             return 12 + regBitParmFlg;
79         }
80         return 0;
81     }
82     if (options.parms_in_bank1 == 0) {
83         /* simple can pass only the first parameter in a register */
84         if (regParmFlg)
85             return 0;
86
87         regParmFlg = 1;
88         return 1;
89     } else {
90         int size = getSize(l);
91         int remain ;
92
93         /* first one goes the usual way to DPTR */
94         if (regParmFlg == 0) {
95             regParmFlg += 4 ;
96             return 1;
97         }
98         /* second one onwards goes to RB1_0 thru RB1_7 */
99         remain = regParmFlg - 4;
100         if (size > (8 - remain)) {
101             regParmFlg = 12 ;
102             return 0;
103         }
104         regParmFlg += size ;
105         return regParmFlg - size + 1;
106     }
107 }
108
109 static bool
110 _mcs51_parseOptions (int *pargc, char **argv, int *i)
111 {
112   /* TODO: allow port-specific command line options to specify
113    * segment names here.
114    */
115   return FALSE;
116 }
117
118 static void
119 _mcs51_finaliseOptions (void)
120 {
121   if (options.noXinitOpt) {
122     port->genXINIT=0;
123   }
124
125   if (options.model == MODEL_LARGE) {
126       port->mem.default_local_map = xdata;
127       port->mem.default_globl_map = xdata;
128     }
129   else
130     {
131       port->mem.default_local_map = data;
132       port->mem.default_globl_map = data;
133     }
134
135   if (options.parms_in_bank1) {
136       addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
137   }
138 }
139
140 static void
141 _mcs51_setDefaultOptions (void)
142 {
143 }
144
145 static const char *
146 _mcs51_getRegName (struct regs *reg)
147 {
148   if (reg)
149     return reg->name;
150   return "err";
151 }
152
153 static void
154 _mcs51_genAssemblerPreamble (FILE * of)
155 {
156     if (options.parms_in_bank1) {
157         int i ;
158         for (i=0; i < 8 ; i++ )
159             fprintf (of,"b1_%d = 0x%x \n",i,8+i);
160     }
161 }
162
163 /* Generate interrupt vector table. */
164 static int
165 _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
166 {
167   int i;
168
169   fprintf (of, "\tljmp\t__sdcc_gsinit_startup\n");
170
171   /* now for the other interrupts */
172   for (i = 0; i < maxInterrupts; i++)
173     {
174       if (interrupts[i])
175         {
176           fprintf (of, "\tljmp\t%s\n", interrupts[i]->rname);
177           if ( i != maxInterrupts - 1 )
178             fprintf (of, "\t.ds\t5\n");
179         }
180       else
181         {
182           fprintf (of, "\treti\n");
183           if ( i != maxInterrupts - 1 )
184             fprintf (of, "\t.ds\t7\n");
185         }
186     }
187   return TRUE;
188 }
189
190 static void
191 _mcs51_genExtraAreas(FILE *of, bool hasMain)
192 {
193   tfprintf (of, "\t!area\n", HOME_NAME);
194   tfprintf (of, "\t!area\n", "GSINIT0 (CODE)");
195   tfprintf (of, "\t!area\n", "GSINIT1 (CODE)");
196   tfprintf (of, "\t!area\n", "GSINIT2 (CODE)");
197   tfprintf (of, "\t!area\n", "GSINIT3 (CODE)");
198   tfprintf (of, "\t!area\n", "GSINIT4 (CODE)");
199   tfprintf (of, "\t!area\n", "GSINIT5 (CODE)");
200   tfprintf (of, "\t!area\n", STATIC_NAME);
201   tfprintf (of, "\t!area\n", port->mem.post_static_name);
202   tfprintf (of, "\t!area\n", CODE_NAME);
203 }
204
205 static void
206 _mcs51_genInitStartup (FILE *of)
207 {
208   tfprintf (of, "\t!global\n", "__sdcc_gsinit_startup");
209   tfprintf (of, "\t!global\n", "__sdcc_program_startup");
210   tfprintf (of, "\t!global\n", "__start__stack");
211
212   if (options.useXstack)
213     {
214       tfprintf (of, "\t!global\n", "__sdcc_init_xstack");
215       tfprintf (of, "\t!global\n", "__start__xstack");
216     }
217
218   // if the port can copy the XINIT segment to XISEG
219   if (port->genXINIT)
220     {
221       port->genXINIT(of);
222     }
223
224   if (!getenv("SDCC_NOGENRAMCLEAR"))
225     tfprintf (of, "\t!global\n", "__mcs51_genRAMCLEAR");
226 }
227
228
229 /* Generate code to copy XINIT to XISEG */
230 static void _mcs51_genXINIT (FILE * of) {
231   tfprintf (of, "\t!global\n", "__mcs51_genXINIT");
232
233   if (!getenv("SDCC_NOGENRAMCLEAR"))
234     tfprintf (of, "\t!global\n", "__mcs51_genXRAMCLEAR");
235 }
236
237
238 /* Do CSE estimation */
239 static bool cseCostEstimation (iCode *ic, iCode *pdic)
240 {
241     operand *result = IC_RESULT(ic);
242     sym_link *result_type = operandType(result);
243
244     /* if it is a pointer then return ok for now */
245     if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
246
247     /* if bitwise | add & subtract then no since mcs51 is pretty good at it
248        so we will cse only if they are local (i.e. both ic & pdic belong to
249        the same basic block */
250     if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
251         /* then if they are the same Basic block then ok */
252         if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
253         else return 0;
254     }
255
256     /* for others it is cheaper to do the cse */
257     return 1;
258 }
259
260 /* Indicate which extended bit operations this port supports */
261 static bool
262 hasExtBitOp (int op, int size)
263 {
264   if (op == RRC
265       || op == RLC
266       || op == GETHBIT
267       || (op == SWAP && size <= 2)
268      )
269     return TRUE;
270   else
271     return FALSE;
272 }
273
274 /* Indicate the expense of an access to an output storage class */
275 static int
276 oclsExpense (struct memmap *oclass)
277 {
278   if (IN_FARSPACE(oclass))
279     return 1;
280
281   return 0;
282 }
283
284
285
286 static int
287 instructionSize(char *inst, char *op1, char *op2)
288 {
289   #define ISINST(s) (strncmp(inst, (s), sizeof(s)-1) == 0)
290   #define IS_A(s) (*(s) == 'a' && *(s+1) == '\0')
291   #define IS_C(s) (*(s) == 'c' && *(s+1) == '\0')
292   #define IS_Rn(s) (*(s) == 'r' && *(s+1) >= '0' && *(s+1) <= '7')
293   #define IS_atRi(s) (*(s) == '@' && *(s+1) == 'r')
294
295   /* Based on the current (2003-08-22) code generation for the
296      small library, the top instruction probability is:
297
298        57% mov/movx/movc
299         6% push
300         6% pop
301         4% inc
302         4% lcall
303         4% add
304         3% clr
305         2% subb
306   */
307   /* mov, push, & pop are the 69% of the cases. Check them first! */
308   if (ISINST ("mov"))
309     {
310       if (*(inst+3)=='x') return 1; /* movx */
311       if (*(inst+3)=='c') return 1; /* movc */
312       if (IS_C (op1) || IS_C (op2)) return 2;
313       if (IS_A (op1))
314         {
315           if (IS_Rn (op2) || IS_atRi (op2)) return 1;
316           return 2;
317         }
318       if (IS_Rn(op1) || IS_atRi(op1))
319         {
320           if (IS_A(op2)) return 1;
321           return 2;
322         }
323       if (strcmp (op1, "dptr") == 0) return 3;
324       if (IS_A (op2) || IS_Rn (op2) || IS_atRi (op2)) return 2;
325       return 3;
326     }
327
328   if (ISINST ("push")) return 2;
329   if (ISINST ("pop")) return 2;
330
331   if (ISINST ("lcall")) return 3;
332   if (ISINST ("ret")) return 1;
333   if (ISINST ("ljmp")) return 3;
334   if (ISINST ("sjmp")) return 2;
335   if (ISINST ("rlc")) return 1;
336   if (ISINST ("rrc")) return 1;
337   if (ISINST ("rl")) return 1;
338   if (ISINST ("rr")) return 1;
339   if (ISINST ("swap")) return 1;
340   if (ISINST ("jc")) return 2;
341   if (ISINST ("jnc")) return 2;
342   if (ISINST ("jb")) return 3;
343   if (ISINST ("jnb")) return 3;
344   if (ISINST ("jbc")) return 3;
345   if (ISINST ("jmp")) return 1; // always jmp @a+dptr
346   if (ISINST ("jz")) return 2;
347   if (ISINST ("jnz")) return 2;
348   if (ISINST ("cjne")) return 3;
349   if (ISINST ("mul")) return 1;
350   if (ISINST ("div")) return 1;
351   if (ISINST ("da")) return 1;
352   if (ISINST ("xchd")) return 1;
353   if (ISINST ("reti")) return 1;
354   if (ISINST ("nop")) return 1;
355   if (ISINST ("acall")) return 2;
356   if (ISINST ("ajmp")) return 2;
357
358
359   if (ISINST ("add") || ISINST ("addc") || ISINST ("subb") || ISINST ("xch"))
360     {
361       if (IS_Rn(op2) || IS_atRi(op2)) return 1;
362       return 2;
363     }
364   if (ISINST ("inc") || ISINST ("dec"))
365     {
366       if (IS_A(op1) || IS_Rn(op1) || IS_atRi(op1)) return 1;
367       if (strcmp(op1, "dptr") == 0) return 1;
368       return 2;
369     }
370   if (ISINST ("anl") || ISINST ("orl") || ISINST ("xrl"))
371     {
372       if (IS_C(op1)) return 2;
373       if (IS_A(op1))
374         {
375           if (IS_Rn(op2) || IS_atRi(op2)) return 1;
376           return 2;
377         }
378       else
379         {
380           if (IS_A(op2)) return 2;
381           return 3;
382         }
383     }
384   if (ISINST ("clr") || ISINST ("setb") || ISINST ("cpl"))
385     {
386       if (IS_A(op1) || IS_C(op1)) return 1;
387       return 2;
388     }
389   if (ISINST ("djnz"))
390     {
391       if (IS_Rn(op1)) return 2;
392       return 3;
393     }
394
395   /* If the instruction is unrecognized, we shouldn't try to optimize. */
396   /* Return a large value to discourage optimization.                  */
397   return 999;
398 }
399
400 static asmLineNode *
401 newAsmLineNode (void)
402 {
403   asmLineNode *aln;
404
405   aln = Safe_alloc ( sizeof (asmLineNode));
406   aln->size = 0;
407   aln->regsRead = NULL;
408   aln->regsWritten = NULL;
409
410   return aln;
411 }
412
413
414 typedef struct mcs51operanddata
415   {
416     char name[6];
417     int regIdx1;
418     int regIdx2;
419   }
420 mcs51operanddata;
421
422 static mcs51operanddata mcs51operandDataTable[] =
423   {
424     {"a", A_IDX, -1},
425     {"ab", A_IDX, B_IDX},
426     {"ac", CND_IDX, -1},
427     {"acc", A_IDX, -1},
428     {"ar0", R0_IDX, -1},
429     {"ar1", R1_IDX, -1},
430     {"ar2", R2_IDX, -1},
431     {"ar3", R3_IDX, -1},
432     {"ar4", R4_IDX, -1},
433     {"ar5", R5_IDX, -1},
434     {"ar6", R6_IDX, -1},
435     {"ar7", R7_IDX, -1},
436     {"b", B_IDX, -1},
437     {"c", CND_IDX, -1},
438     {"cy", CND_IDX, -1},
439     {"dph", DPH_IDX, -1},
440     {"dpl", DPL_IDX, -1},
441     {"dptr", DPL_IDX, DPH_IDX},
442     {"f0", CND_IDX, -1},
443     {"f1", CND_IDX, -1},
444     {"ov", CND_IDX, -1},
445     {"p", CND_IDX, -1},
446     {"psw", CND_IDX, -1},
447     {"r0", R0_IDX, -1},
448     {"r1", R1_IDX, -1},
449     {"r2", R2_IDX, -1},
450     {"r3", R3_IDX, -1},
451     {"r4", R4_IDX, -1},
452     {"r5", R5_IDX, -1},
453     {"r6", R6_IDX, -1},
454     {"r7", R7_IDX, -1},
455   };
456
457 static int
458 mcs51operandCompare (const void *key, const void *member)
459 {
460   return strcmp((const char *)key, ((mcs51operanddata *)member)->name);
461 }
462
463 static void
464 updateOpRW (asmLineNode *aln, char *op, char *optype)
465 {
466   mcs51operanddata *opdat;
467   char *dot;
468
469   dot = strchr(op, '.');
470   if (dot)
471     *dot = '\0';
472
473   opdat = bsearch (op, mcs51operandDataTable,
474                    sizeof(mcs51operandDataTable)/sizeof(mcs51operanddata),
475                    sizeof(mcs51operanddata), mcs51operandCompare);
476
477   if (opdat && strchr(optype,'r'))
478     {
479       if (opdat->regIdx1 >= 0)
480         aln->regsRead = bitVectSetBit (aln->regsRead, opdat->regIdx1);
481       if (opdat->regIdx2 >= 0)
482         aln->regsRead = bitVectSetBit (aln->regsRead, opdat->regIdx2);
483     }
484   if (opdat && strchr(optype,'w'))
485     {
486       if (opdat->regIdx1 >= 0)
487         aln->regsWritten = bitVectSetBit (aln->regsWritten, opdat->regIdx1);
488       if (opdat->regIdx2 >= 0)
489         aln->regsWritten = bitVectSetBit (aln->regsWritten, opdat->regIdx2);
490     }
491   if (op[0] == '@')
492     {
493       if (!strcmp(op, "@r0"))
494         aln->regsRead = bitVectSetBit (aln->regsRead, R0_IDX);
495       if (!strcmp(op, "@r1"))
496         aln->regsRead = bitVectSetBit (aln->regsRead, R1_IDX);
497       if (strstr(op, "dptr"))
498         {
499           aln->regsRead = bitVectSetBit (aln->regsRead, DPL_IDX);
500           aln->regsRead = bitVectSetBit (aln->regsRead, DPH_IDX);
501         }
502       if (strstr(op, "a+"))
503         aln->regsRead = bitVectSetBit (aln->regsRead, A_IDX);
504     }
505 }
506
507 typedef struct mcs51opcodedata
508   {
509     char name[6];
510     char class[3];
511     char pswtype[3];
512     char op1type[3];
513     char op2type[3];
514   }
515 mcs51opcodedata;
516
517 static mcs51opcodedata mcs51opcodeDataTable[] =
518   {
519     {"acall","j", "",   "",   ""},
520     {"add",  "",  "w",  "rw", "r"},
521     {"addc", "",  "rw", "rw", "r"},
522     {"ajmp", "j", "",   "",   ""},
523     {"anl",  "",  "",   "rw", "r"},
524     {"cjne", "j", "w",  "r",  "r"},
525     {"clr",  "",  "",   "w",  ""},
526     {"cpl",  "",  "",   "rw", ""},
527     {"da",   "",  "rw", "rw", ""},
528     {"dec",  "",  "",   "rw", ""},
529     {"div",  "",  "w",  "rw", ""},
530     {"djnz", "j", "",  "rw",  ""},
531     {"inc",  "",  "",   "rw", ""},
532     {"jb",   "j", "",   "r",  ""},
533     {"jbc",  "j", "",  "rw",  ""},
534     {"jc",   "j", "",   "",   ""},
535     {"jmp",  "j", "",  "",    ""},
536     {"jnb",  "j", "",   "r",  ""},
537     {"jnc",  "j", "",   "",   ""},
538     {"jnz",  "j", "",  "",    ""},
539     {"jz",   "j", "",  "",    ""},
540     {"lcall","j", "",   "",   ""},
541     {"ljmp", "j", "",   "",   ""},
542     {"mov",  "",  "",   "w",  "r"},
543     {"movc", "",  "",   "w",  "r"},
544     {"movx", "",  "",   "w",  "r"},
545     {"mul",  "",  "w",  "rw", ""},
546     {"nop",  "",  "",   "",   ""},
547     {"orl",  "",  "",   "rw", "r"},
548     {"pop",  "",  "",   "w",  ""},
549     {"push", "",  "",   "r",  ""},
550     {"ret",  "j", "",   "",   ""},
551     {"reti", "j", "",   "",   ""},
552     {"rl",   "",  "",   "rw", ""},
553     {"rlc",  "",  "rw", "rw", ""},
554     {"rr",   "",  "",   "rw", ""},
555     {"rrc",  "",  "rw", "rw", ""},
556     {"setb", "",  "",   "w",  ""},
557     {"sjmp", "j", "",   "",   ""},
558     {"subb", "",  "rw", "rw", "r"},
559     {"swap", "",  "",   "rw", ""},
560     {"xch",  "",  "",   "rw", "rw"},
561     {"xchd", "",  "",   "rw", "rw"},
562     {"xrl",  "",  "",   "rw", "r"},
563   };
564
565 static int
566 mcs51opcodeCompare (const void *key, const void *member)
567 {
568   return strcmp((const char *)key, ((mcs51opcodedata *)member)->name);
569 }
570
571 static asmLineNode *
572 asmLineNodeFromLineNode (lineNode *ln)
573 {
574   asmLineNode *aln = newAsmLineNode();
575   char *op, op1[256], op2[256];
576   int opsize;
577   const unsigned char *p;
578   char inst[8];
579   mcs51opcodedata *opdat;
580
581   p = ln->line;
582
583   while (*p && isspace(*p)) p++;
584   for (op = inst, opsize=1; *p; p++)
585     {
586       if (isspace(*p) || *p == ';' || *p == ':' || *p == '=')
587         break;
588       else
589         if (opsize < sizeof(inst))
590           *op++ = tolower(*p), opsize++;
591     }
592   *op = '\0';
593
594   if (*p == ';' || *p == ':' || *p == '=')
595     return aln;
596
597   while (*p && isspace(*p)) p++;
598   if (*p == '=')
599     return aln;
600
601   for (op = op1, opsize=1; *p && *p != ','; p++)
602     {
603       if (!isspace(*p) && opsize < sizeof(op1))
604         *op++ = tolower(*p), opsize++;
605     }
606   *op = '\0';
607
608   if (*p == ',') p++;
609   for (op = op2, opsize=1; *p && *p != ','; p++)
610     {
611       if (!isspace(*p) && opsize < sizeof(op2))
612         *op++ = tolower(*p), opsize++;
613     }
614   *op = '\0';
615
616   aln->size = instructionSize(inst, op1, op2);
617
618   aln->regsRead = newBitVect (END_IDX);
619   aln->regsWritten = newBitVect (END_IDX);
620
621   opdat = bsearch (inst, mcs51opcodeDataTable,
622                    sizeof(mcs51opcodeDataTable)/sizeof(mcs51opcodedata),
623                    sizeof(mcs51opcodedata), mcs51opcodeCompare);
624
625   if (opdat)
626     {
627       updateOpRW (aln, op1, opdat->op1type);
628       updateOpRW (aln, op2, opdat->op2type);
629       if (strchr(opdat->pswtype,'r'))
630         aln->regsRead = bitVectSetBit (aln->regsRead, CND_IDX);
631       if (strchr(opdat->pswtype,'w'))
632         aln->regsWritten = bitVectSetBit (aln->regsWritten, CND_IDX);
633     }
634
635   return aln;
636 }
637
638 static int
639 getInstructionSize (lineNode *line)
640 {
641   if (!line->aln)
642     line->aln = asmLineNodeFromLineNode (line);
643
644   return line->aln->size;
645 }
646
647 static bitVect *
648 getRegsRead (lineNode *line)
649 {
650   if (!line->aln)
651     line->aln = asmLineNodeFromLineNode (line);
652
653   return line->aln->regsRead;
654 }
655
656 static bitVect *
657 getRegsWritten (lineNode *line)
658 {
659   if (!line->aln)
660     line->aln = asmLineNodeFromLineNode (line);
661
662   return line->aln->regsWritten;
663 }
664
665
666 /** $1 is always the basename.
667     $2 is always the output file.
668     $3 varies
669     $l is the list of extra options that should be there somewhere...
670     MUST be terminated with a NULL.
671 */
672 static const char *_linkCmd[] =
673 {
674   "aslink", "-nf", "\"$1\"", NULL
675 };
676
677 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
678 static const char *_asmCmd[] =
679 {
680   "asx8051", "$l", "$3", "\"$1.asm\"", NULL
681 };
682
683 /* Globals */
684 PORT mcs51_port =
685 {
686   TARGET_ID_MCS51,
687   "mcs51",
688   "MCU 8051",                   /* Target name */
689   NULL,                         /* Processor name */
690   {
691     glue,
692     TRUE,                       /* Emit glue around main */
693     MODEL_SMALL | MODEL_LARGE,
694     MODEL_SMALL
695   },
696   {
697     _asmCmd,
698     NULL,
699     "-plosgffc",                /* Options with debug */
700     "-plosgff",                 /* Options without debug */
701     0,
702     ".asm",
703     NULL                        /* no do_assemble function */
704   },
705   {
706     _linkCmd,
707     NULL,
708     NULL,
709     ".rel",
710     1
711   },
712   {
713     _defaultRules,
714     getInstructionSize,
715     getRegsRead,
716     getRegsWritten
717   },
718   {
719     /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
720     1, 2, 2, 4, 1, 2, 3, 1, 4, 4
721   },
722   {
723     "XSTK    (PAG,XDATA)",      // xstack_name
724     "STACK   (DATA)",           // istack_name
725     "CSEG    (CODE)",           // code_name
726     "DSEG    (DATA)",           // data_name
727     "ISEG    (DATA)",           // idata_name
728     "PSEG    (PAG,XDATA)",      // pdata_name
729     "XSEG    (XDATA)",          // xdata_name
730     "BSEG    (BIT)",            // bit_name
731     "RSEG    (DATA)",           // reg_name
732     "GSINIT  (CODE)",           // static_name
733     "OSEG    (OVR,DATA)",       // overlay_name
734     "GSFINAL (CODE)",           // post_static_name
735     "HOME    (CODE)",           // home_name
736     "XISEG   (XDATA)",          // xidata_name - initialized xdata   initialized xdata
737     "XINIT   (CODE)",           // xinit_name - a code copy of xiseg
738     "CONST   (CODE)",           // const_name - const data (code or not)
739     NULL,
740     NULL,
741     1
742   },
743   { _mcs51_genExtraAreas, NULL },
744   {
745     +1,         /* direction (+1 = stack grows up) */
746     0,          /* bank_overhead (switch between register banks) */
747     4,          /* isr_overhead */
748     1,          /* call_overhead (2 for return address - 1 for pre-incrementing push */
749     1,          /* reent_overhead */
750     0           /* banked_overhead (switch between code banks) */
751   },
752   {
753     /* mcs51 has an 8 bit mul */
754     1, -1
755   },
756   {
757     mcs51_emitDebuggerSymbol
758   },
759   {
760     256,        /* maxCount */
761     2,          /* sizeofElement */
762     {6,9,15},   /* sizeofMatchJump[] */
763     {9,18,36},  /* sizeofRangeCompare[] */
764     4,          /* sizeofSubtract */
765     6,          /* sizeofDispatch */
766   },
767   "_",
768   _mcs51_init,
769   _mcs51_parseOptions,
770   NULL,
771   NULL,
772   _mcs51_finaliseOptions,
773   _mcs51_setDefaultOptions,
774   mcs51_assignRegisters,
775   _mcs51_getRegName,
776   _mcs51_keywords,
777   _mcs51_genAssemblerPreamble,
778   NULL,                         /* no genAssemblerEnd */
779   _mcs51_genIVT,
780   _mcs51_genXINIT,
781   _mcs51_genInitStartup,
782   _mcs51_reset_regparm,
783   _mcs51_regparm,
784   NULL,
785   NULL,
786   NULL,
787   hasExtBitOp,                  /* hasExtBitOp */
788   oclsExpense,                  /* oclsExpense */
789   FALSE,
790   TRUE,                         /* little endian */
791   0,                            /* leave lt */
792   0,                            /* leave gt */
793   1,                            /* transform <= to ! > */
794   1,                            /* transform >= to ! < */
795   1,                            /* transform != to !(a == b) */
796   0,                            /* leave == */
797   FALSE,                        /* No array initializer support. */
798   cseCostEstimation,
799   NULL,                         /* no builtin functions */
800   GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
801   1,                            /* reset labelKey to 1 */
802   1,                            /* globals & local static allowed */
803   PORT_MAGIC
804 };