2 xa51 specific general functions.
10 static char _defaultRules[] =
15 /* list of key words used by xa51 */
16 static char *_xa51_keywords[] =
46 void _xa51_genAssemblerEnd (FILE * of)
48 //fprintf (stderr, "Did %d rewind%c for c-line in asm comments\n", rewinds,
49 //rewinds==1 ? '\0' : 's');
52 void xa51_assignRegisters (eBBlock ** ebbs, int count);
54 static int regParmFlg = 0; /* determine if we can register a parameter */
59 asm_addTree (&asm_xa_asm_mapping);
63 _xa51_reset_regparm ()
69 _xa51_regparm (sym_link * l)
72 /* for this processor it is simple
73 can pass only the first parameter in a register */
82 _xa51_parseOptions (int *pargc, char **argv, int *i)
84 /* TODO: allow port-specific command line options to specify
91 _xa51_finaliseOptions (void)
93 fprintf (stderr, "*** WARNING *** The XA51 port isn't yet complete\n");
94 port->mem.default_local_map = istack;
95 port->mem.default_globl_map = xdata;
96 if (options.model!=MODEL_PAGE0) {
97 fprintf (stderr, "-mxa51 only supports --model-page0\n");
103 _xa51_setDefaultOptions (void)
106 options.intlong_rent=1;
107 options.float_rent=1;
108 options.stack_loc=0x100;
113 _xa51_getRegName (struct regs *reg)
120 /* Generate interrupt vector table. */
122 _xa51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
127 /* Generate code to copy XINIT to XISEG */
128 static void _xa51_genXINIT (FILE * of) {
129 fprintf (of, "; _xa51_genXINIT() start\n");
130 fprintf (of, " mov r0,#l_XINIT\n");
131 fprintf (of, " beq 00002$\n");
132 fprintf (of, " mov r1,#s_XINIT\n");
133 fprintf (of, " mov r2,#s_XISEG\n");
134 fprintf (of, "00001$: movc r3l,[r1+]\n");
135 fprintf (of, " mov [r2+],r3l\n");
136 fprintf (of, " djnz r0,00001$\n");
137 fprintf (of, "00002$:\n");
138 fprintf (of, "; _xa51_genXINIT() end\n");
142 _xa51_genAssemblerPreamble (FILE * of)
144 symbol *mainExists=newSymbol("main", 0);
147 if ((mainExists=findSymWithLevel(SymbolTab, mainExists))) {
148 fprintf (of, "\t.area GSINIT\t(CODE)\n");
149 fprintf (of, "__interrupt_vect:\n");
150 fprintf (of, "\t.dw\t0x8f00\n");
151 fprintf (of, "\t.dw\t__sdcc_gsinit_startup\n");
153 fprintf (of, "__sdcc_gsinit_startup:\n");
154 fprintf (of, ";\tmov.b\t_SCR,#0x01\t; page zero mode\n");
155 fprintf (of, "\t.db 0x96,0x48,0x40,0x01\n");
156 fprintf (of, "\tmov\tr7,#0x%04x\n", options.stack_loc);
157 fprintf (of, "\tcall\t_external_startup\n");
159 fprintf (of, "\t.area CSEG\t(CODE)\n");
160 fprintf (of, "\tcall\t_main\n");
161 fprintf (of, "\treset\t;main should not return\n");
165 /* dummy linker for now */
169 /* Do CSE estimation */
170 static bool cseCostEstimation (iCode *ic, iCode *pdic)
172 operand *result = IC_RESULT(ic);
173 sym_link *result_type = operandType(result);
175 /* if it is a pointer then return ok for now */
176 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
178 /* if bitwise | add & subtract then no since xa51 is pretty good at it
179 so we will cse only if they are local (i.e. both ic & pdic belong to
180 the same basic block */
181 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
182 /* then if they are the same Basic block then ok */
183 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
187 /* for others it is cheaper to do the cse */
191 /** $1 is always the basename.
192 $2 is always the output file.
194 $l is the list of extra options that should be there somewhere...
195 MUST be terminated with a NULL.
197 static const char *_linkCmd[] =
199 "xa_link", "", "\"$1\"", NULL
202 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
203 static const char *_asmCmd[] =
205 "xa_rasm", "$l", "$3", "\"$1.asm\"", NULL
213 "MCU 80C51XA", /* Target name */
214 NULL, /* Processor name */
217 FALSE, /* Emit glue around main */
224 "", /* Options with debug */
225 "", /* Options without debug */
228 NULL /* no do_assemble function */
240 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
241 1, 2, 2, 4, 2, 2, 3, 1, 4, 4
248 NULL, //"ISEG (DATA)",
251 NULL, //"RSEG (DATA)",
253 NULL, //"OSEG (OVR,XDATA)",
256 "XISEG (XDATA)", // initialized xdata
257 "XINIT (CODE)", // a code copy of xiseg
258 NULL, // default local map
259 NULL, // default global map
264 -1, // stack grows down
265 0, // bank overhead NUY
266 4, // isr overhead, page zero mode
267 2, // function call overhead, page zero mode
268 0, // reentrant overhead NUY
269 0 // banked overhead NUY
271 /* xa51 has an 16 bit mul */
279 _xa51_finaliseOptions,
280 _xa51_setDefaultOptions,
281 xa51_assignRegisters,
284 _xa51_genAssemblerPreamble,
285 _xa51_genAssemblerEnd,
290 NULL, // process_pragma()
291 NULL, // getMangledFunctionName()
292 NULL, // hasNativeMulFor()
293 TRUE, // use_dw_for_init
294 TRUE, /* little endian */
297 1, /* transform <= to ! > */
298 1, /* transform >= to ! < */
299 1, /* transform != to !(a == b) */
301 FALSE, /* No array initializer support. */
303 NULL, /* no builtin functions */
304 GPOINTER, /* treat unqualified pointers as "generic" pointers */
305 1, /* reset labelKey to 1 */
306 1, /* globals & local static allowed */