2 xa51 specific general functions.
4 Note that mlh prepended _xa51_ 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 xa51 */
18 static char *_xa51_keywords[] =
48 void _xa51_genAssemblerEnd () {
49 fprintf (stderr, "Did %d rewind%c for c-line in asm comments\n", rewinds,
50 rewinds==1 ? '\0' : 's');
53 void xa51_assignRegisters (eBBlock ** ebbs, int count);
55 static int regParmFlg = 0; /* determine if we can register a parameter */
60 asm_addTree (&asm_asxxxx_mapping);
64 _xa51_reset_regparm ()
70 _xa51_regparm (sym_link * l)
73 /* for this processor it is simple
74 can pass only the first parameter in a register */
83 _xa51_parseOptions (int *pargc, char **argv, int *i)
85 /* TODO: allow port-specific command line options to specify
92 _xa51_finaliseOptions (void)
94 port->mem.default_local_map = istack;
95 port->mem.default_globl_map = xdata;
99 _xa51_setDefaultOptions (void)
102 options.intlong_rent=1;
103 options.float_rent=1;
107 _xa51_getRegName (struct regs *reg)
115 _xa51_genAssemblerPreamble (FILE * of)
119 /* Generate interrupt vector table. */
121 _xa51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
126 /* Generate code to copy XINIT to XISEG */
127 static void _xa51_genXINIT (FILE * of) {
128 fprintf (of, "; _xa51_genXINIT() start\n");
129 fprintf (of, " mov a,#l_XINIT\n");
130 fprintf (of, " orl a,#l_XINIT>>8\n");
131 fprintf (of, " jz 00003$\n");
132 fprintf (of, " mov a,#s_XINIT\n");
133 fprintf (of, " add a,#l_XINIT\n");
134 fprintf (of, " mov r1,a\n");
135 fprintf (of, " mov a,#s_XINIT>>8\n");
136 fprintf (of, " addc a,#l_XINIT>>8\n");
137 fprintf (of, " mov r2,a\n");
138 fprintf (of, " mov dptr,#s_XINIT\n");
139 fprintf (of, " mov r0,#s_XISEG\n");
140 fprintf (of, " mov p2,#(s_XISEG >> 8)\n");
141 fprintf (of, "00001$: clr a\n");
142 fprintf (of, " movc a,@a+dptr\n");
143 fprintf (of, " movx @r0,a\n");
144 fprintf (of, " inc dptr\n");
145 fprintf (of, " inc r0\n");
146 fprintf (of, " cjne r0,#0,00002$\n");
147 fprintf (of, " inc p2\n");
148 fprintf (of, "00002$: mov a,dpl\n");
149 fprintf (of, " cjne a,ar1,00001$\n");
150 fprintf (of, " mov a,dph\n");
151 fprintf (of, " cjne a,ar2,00001$\n");
152 fprintf (of, " mov p2,#0xFF\n");
153 fprintf (of, "00003$:\n");
154 fprintf (of, "; _xa51_genXINIT() end\n");
158 /* Do CSE estimation */
159 static bool cseCostEstimation (iCode *ic, iCode *pdic)
161 operand *result = IC_RESULT(ic);
162 sym_link *result_type = operandType(result);
164 /* if it is a pointer then return ok for now */
165 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
167 /* if bitwise | add & subtract then no since xa51 is pretty good at it
168 so we will cse only if they are local (i.e. both ic & pdic belong to
169 the same basic block */
170 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
171 /* then if they are the same Basic block then ok */
172 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
176 /* for others it is cheaper to do the cse */
180 /** $1 is always the basename.
181 $2 is always the output file.
183 $l is the list of extra options that should be there somewhere...
184 MUST be terminated with a NULL.
186 static const char *_linkCmd[] =
188 "{bindir}{sep}aslink", "-nf", "$1", NULL
191 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
192 static const char *_asmCmd[] =
194 "xa_asm", "$l", "$3", "$1.asm", NULL
202 "MCU 80C51XA", /* Target name */
204 TRUE, /* Emit glue around main */
211 "-plosgffc", /* Options with debug */
212 "-plosgff", /* Options without debug */
215 NULL /* no do_assemble function */
227 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
228 1, 2, 2, 4, 2, 2, 3, 1, 4, 4
243 "XISEG (XDATA)", // initialized xdata
244 "XINIT (CODE)", // a code copy of xiseg
245 NULL, // default local map
246 NULL, // default global map
250 -1, // stack grows down
251 0, // bank overhead NUY
253 4, // function call overhead
254 0, // reentrant overhead NUY
255 0 // banked overhead NUY
257 /* xa51 has an 16 bit mul */
264 _xa51_finaliseOptions,
265 _xa51_setDefaultOptions,
266 xa51_assignRegisters,
269 _xa51_genAssemblerPreamble,
270 _xa51_genAssemblerEnd,
275 NULL, // process_pragma()
276 NULL, // getMangledFunctionName()
277 NULL, // hasNativeMulFor()
278 TRUE, // use_dw_for_init
281 0, /* transform <= to ! > */
282 0, /* transform >= to ! < */
283 0, /* transform != to !(a == b) */
285 FALSE, /* No array initializer support. */
287 NULL, /* no builtin functions */
288 GPOINTER, /* treat unqualified pointers as "generic" pointers */
289 1, /* reset labelKey to 1 */
290 1, /* globals & local static allowed */