2 mcs51 specific general functions.
4 Note that mlh prepended _mcs51_ on the static functions. Makes
5 it easier to set a breakpoint using the debugger.
12 static char _defaultRules[] =
17 /* list of key words used by msc51 */
18 static char *_mcs51_keywords[] =
48 void mcs51_assignRegisters (eBBlock ** ebbs, int count);
50 static int regParmFlg = 0; /* determine if we can register a parameter */
55 asm_addTree (&asm_asxxxx_mapping);
59 _mcs51_reset_regparm ()
65 _mcs51_regparm (sym_link * l)
67 /* for this processor it is simple
68 can pass only the first parameter in a register */
77 _mcs51_parseOptions (int *pargc, char **argv, int *i)
79 /* TODO: allow port-specific command line options to specify
86 _mcs51_finaliseOptions (void)
88 if (options.model == MODEL_LARGE) {
89 port->mem.default_local_map = xdata;
90 port->mem.default_globl_map = xdata;
94 port->mem.default_local_map = data;
95 port->mem.default_globl_map = data;
100 _mcs51_setDefaultOptions (void)
105 _mcs51_getRegName (struct regs *reg)
113 _mcs51_genAssemblerPreamble (FILE * of)
117 /* Generate interrupt vector table. */
119 _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
124 /* Generate code to copy XINIT to XISEG */
125 static void _mcs51_genXINIT (FILE * of) {
126 fprintf (of, "; _mcs51_genXINIT() start\n");
127 fprintf (of, " mov a,#l_XINIT\n");
128 fprintf (of, " orl a,#l_XINIT>>8\n");
129 fprintf (of, " jz 00003$\n");
130 fprintf (of, " mov a,#s_XINIT\n");
131 fprintf (of, " add a,#l_XINIT\n");
132 fprintf (of, " mov r1,a\n");
133 fprintf (of, " mov a,#s_XINIT>>8\n");
134 fprintf (of, " addc a,#l_XINIT>>8\n");
135 fprintf (of, " mov r2,a\n");
136 fprintf (of, " mov dptr,#s_XINIT\n");
137 fprintf (of, " mov r0,#s_XISEG\n");
138 fprintf (of, " mov p2,#(s_XISEG >> 8)\n");
139 fprintf (of, "00001$: clr a\n");
140 fprintf (of, " movc a,@a+dptr\n");
141 fprintf (of, " movx @r0,a\n");
142 fprintf (of, " inc dptr\n");
143 fprintf (of, " inc r0\n");
144 fprintf (of, " cjne r0,#0,00002$\n");
145 fprintf (of, " inc p2\n");
146 fprintf (of, "00002$: mov a,dpl\n");
147 fprintf (of, " cjne a,ar1,00001$\n");
148 fprintf (of, " mov a,dph\n");
149 fprintf (of, " cjne a,ar2,00001$\n");
150 fprintf (of, " mov p2,#0xFF\n");
151 fprintf (of, "00003$:\n");
152 fprintf (of, "; _mcs51_genXINIT() end\n");
156 /* Do CSE estimation */
157 static bool cseCostEstimation (iCode *ic, iCode *pdic)
159 operand *result = IC_RESULT(ic);
160 sym_link *result_type = operandType(result);
162 /* if it is a pointer then return ok for now */
163 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
165 /* if bitwise | add & subtract then no since mcs51 is pretty good at it
166 so we will cse only if they are local (i.e. both ic & pdic belong to
167 the same basic block */
168 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
169 /* then if they are the same Basic block then ok */
170 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
174 /* for others it is cheaper to do the cse */
178 /** $1 is always the basename.
179 $2 is always the output file.
181 $l is the list of extra options that should be there somewhere...
182 MUST be terminated with a NULL.
184 static const char *_linkCmd[] =
186 "{bindir}{sep}aslink", "-nf", "$1", NULL
189 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
190 static const char *_asmCmd[] =
192 "asx8051", "$l", "$3", "$1.asm", NULL
200 "MCU 8051", /* Target name */
202 TRUE, /* Emit glue around main */
203 MODEL_SMALL | MODEL_LARGE,
209 "-plosgffc", /* Options with debug */
210 "-plosgff", /* Options without debug */
213 NULL /* no do_assemble function */
225 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
226 1, 2, 2, 4, 1, 2, 3, 1, 4, 4
241 "XISEG (XDATA)", // initialized xdata
242 "XINIT (CODE)", // a code copy of xiseg
250 /* mcs51 has an 8 bit mul */
257 _mcs51_finaliseOptions,
258 _mcs51_setDefaultOptions,
259 mcs51_assignRegisters,
262 _mcs51_genAssemblerPreamble,
263 NULL, /* no genAssemblerEnd */
266 _mcs51_reset_regparm,
274 1, /* transform <= to ! > */
275 1, /* transform >= to ! < */
276 1, /* transform != to !(a == b) */
278 FALSE, /* No array initializer support. */
280 NULL, /* no builtin functions */
281 GPOINTER, /* treat unqualified pointers as "generic" pointers */
282 1, /* reset labelKey to 1 */
283 1, /* globals & local static allowed */