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