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[] =
47 void mcs51_assignRegisters (eBBlock ** ebbs, int count);
49 static int regParmFlg = 0; /* determine if we can register a parameter */
54 asm_addTree (&asm_asxxxx_mapping);
58 _mcs51_reset_regparm ()
64 _mcs51_regparm (sym_link * l)
66 /* for this processor it is simple
67 can pass only the first parameter in a register */
76 _mcs51_parseOptions (int *pargc, char **argv, int *i)
78 /* TODO: allow port-specific command line options to specify
85 _mcs51_finaliseOptions (void)
87 if (options.model == MODEL_LARGE) {
88 port->mem.default_local_map = xdata;
89 port->mem.default_globl_map = xdata;
93 port->mem.default_local_map = data;
94 port->mem.default_globl_map = data;
99 _mcs51_setDefaultOptions (void)
104 _mcs51_getRegName (struct regs *reg)
112 _mcs51_genAssemblerPreamble (FILE * of)
116 /* Generate interrupt vector table. */
118 _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
123 /* Generate code to copy XINIT to XISEG */
124 static void _mcs51_genXINIT (FILE * of) {
125 fprintf (of, "; _mcs51_genXINIT() start\n");
126 fprintf (of, " mov a,#l_XINIT\n");
127 fprintf (of, " orl a,#l_XINIT>>8\n");
128 fprintf (of, " jz 00003$\n");
129 fprintf (of, " mov a,#s_XINIT\n");
130 fprintf (of, " add a,#l_XINIT\n");
131 fprintf (of, " mov r1,a\n");
132 fprintf (of, " mov a,#s_XINIT>>8\n");
133 fprintf (of, " addc a,#l_XINIT>>8\n");
134 fprintf (of, " mov r2,a\n");
135 fprintf (of, " mov dptr,#s_XINIT\n");
136 fprintf (of, " mov r0,#s_XISEG\n");
137 fprintf (of, " mov p2,#(s_XISEG >> 8)\n");
138 fprintf (of, "00001$: clr a\n");
139 fprintf (of, " movc a,@a+dptr\n");
140 fprintf (of, " movx @r0,a\n");
141 fprintf (of, " inc dptr\n");
142 fprintf (of, " inc r0\n");
143 fprintf (of, " cjne r0,#0,00002$\n");
144 fprintf (of, " inc p2\n");
145 fprintf (of, "00002$: mov a,dpl\n");
146 fprintf (of, " cjne a,ar1,00001$\n");
147 fprintf (of, " mov a,dph\n");
148 fprintf (of, " cjne a,ar2,00001$\n");
149 fprintf (of, " mov p2,#0xFF\n");
150 fprintf (of, "00003$:\n");
151 fprintf (of, "; _mcs51_genXINIT() end\n");
155 /* Do CSE estimation */
156 static bool cseCostEstimation (iCode *ic, iCode *pdic)
158 operand *result = IC_RESULT(ic);
159 sym_link *result_type = operandType(result);
161 /* if it is a pointer then return ok for now */
162 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
164 /* if bitwise | add & subtract then no since mcs51 is pretty good at it
165 so we will cse only if they are local (i.e. both ic & pdic belong to
166 the same basic block */
167 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
168 /* then if they are the same Basic block then ok */
169 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
173 /* for others it is cheaper to do the cse */
177 /** $1 is always the basename.
178 $2 is always the output file.
180 $l is the list of extra options that should be there somewhere...
181 MUST be terminated with a NULL.
183 static const char *_linkCmd[] =
185 "{bindir}{sep}aslink", "-nf", "$1", NULL
188 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
189 static const char *_asmCmd[] =
191 "asx8051", "$l", "$3", "$1.asm", NULL
199 "MCU 8051", /* Target name */
201 TRUE, /* Emit glue around main */
202 MODEL_SMALL | MODEL_LARGE,
208 "-plosgffc", /* Options with debug */
209 "-plosgff", /* Options without debug */
223 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
224 1, 2, 2, 4, 1, 2, 3, 1, 4, 4
239 "XISEG (XDATA)", // initialized xdata
240 "XINIT (CODE)", // a code copy of xiseg
248 /* mcs51 has an 8 bit mul */
255 _mcs51_finaliseOptions,
256 _mcs51_setDefaultOptions,
257 mcs51_assignRegisters,
260 _mcs51_genAssemblerPreamble,
263 _mcs51_reset_regparm,
271 1, /* transform <= to ! > */
272 1, /* transform >= to ! < */
273 1, /* transform != to !(a == b) */
275 FALSE, /* No array initializer support. */
277 NULL, /* no builtin functions */