2 xa51 specific general functions.
10 static char _defaultRules[] =
15 /* list of key words used by xa51 */
16 static char *_xa51_keywords[] =
45 /* rewinds declared in asm.c, function printCLine().
46 * Currently commented out.
50 void _xa51_genAssemblerEnd (FILE * of)
52 //fprintf (stderr, "Did %d rewind%c for c-line in asm comments\n", rewinds,
53 //rewinds==1 ? '\0' : 's');
56 void xa51_assignRegisters (ebbIndex *);
58 static int regParmFlg = 0; /* determine if we can register a parameter */
63 asm_addTree (&asm_xa_asm_mapping);
67 _xa51_reset_regparm (void)
73 _xa51_regparm (sym_link * l, bool reentrant)
76 /* for this processor it is simple
77 can pass only the first parameter in a register */
86 _xa51_parseOptions (int *pargc, char **argv, int *i)
88 /* TODO: allow port-specific command line options to specify
95 _xa51_finaliseOptions (void)
97 fprintf (stderr, "*** WARNING *** The XA51 port isn't yet complete\n");
98 port->mem.default_local_map = istack;
99 port->mem.default_globl_map = xdata;
100 if (options.model!=MODEL_PAGE0) {
101 fprintf (stderr, "-mxa51 only supports --model-page0\n");
107 _xa51_setDefaultOptions (void)
110 options.intlong_rent=1;
111 options.float_rent=1;
112 options.stack_loc=0x100;
117 _xa51_getRegName (struct regs *reg)
124 /* Generate interrupt vector table. */
126 _xa51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
131 /* Generate code to copy XINIT to XISEG */
132 static void _xa51_genXINIT (FILE * of) {
133 fprintf (of, "; _xa51_genXINIT() start\n");
134 fprintf (of, " mov r0,#l_XINIT\n");
135 fprintf (of, " beq 00002$\n");
136 fprintf (of, " mov r1,#s_XINIT\n");
137 fprintf (of, " mov r2,#s_XISEG\n");
138 fprintf (of, "00001$: movc r3l,[r1+]\n");
139 fprintf (of, " mov [r2+],r3l\n");
140 fprintf (of, " djnz r0,00001$\n");
141 fprintf (of, "00002$:\n");
142 fprintf (of, "; _xa51_genXINIT() end\n");
146 _xa51_genAssemblerPreamble (FILE * of)
148 symbol *mainExists=newSymbol("main", 0);
151 if ((mainExists=findSymWithLevel(SymbolTab, mainExists))) {
152 fprintf (of, "\t.area GSINIT\t(CODE)\n");
153 fprintf (of, "__interrupt_vect:\n");
154 fprintf (of, "\t.dw\t0x8f00\n");
155 fprintf (of, "\t.dw\t__sdcc_gsinit_startup\n");
157 fprintf (of, "__sdcc_gsinit_startup:\n");
158 fprintf (of, ";\tmov.b\t_SCR,#0x01\t; page zero mode\n");
159 fprintf (of, "\t.db 0x96,0x48,0x40,0x01\n");
160 fprintf (of, "\tmov\tr7,#0x%04x\n", options.stack_loc);
161 fprintf (of, "\tcall\t_external_startup\n");
163 fprintf (of, "\t.area CSEG\t(CODE)\n");
164 fprintf (of, "\tcall\t_main\n");
165 fprintf (of, "\treset\t;main should not return\n");
169 /* dummy linker for now */
173 /* Do CSE estimation */
174 static bool cseCostEstimation (iCode *ic, iCode *pdic)
176 operand *result = IC_RESULT(ic);
177 sym_link *result_type = operandType(result);
179 /* if it is a pointer then return ok for now */
180 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
182 /* if bitwise | add & subtract then no since xa51 is pretty good at it
183 so we will cse only if they are local (i.e. both ic & pdic belong to
184 the same basic block */
185 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
186 /* then if they are the same Basic block then ok */
187 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
191 /* for others it is cheaper to do the cse */
195 /* Indicate which extended bit operations this port supports */
197 hasExtBitOp (int op, int size)
208 /* Indicate the expense of an access to an output storage class */
210 oclsExpense (struct memmap *oclass)
212 if (IN_FARSPACE(oclass))
219 /** $1 is always the basename.
220 $2 is always the output file.
222 $l is the list of extra options that should be there somewhere...
223 MUST be terminated with a NULL.
225 static const char *_linkCmd[] =
227 "xa_link", "", "\"$1\"", NULL
230 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
231 static const char *_asmCmd[] =
233 "xa_rasm", "$l", "$3", "\"$1.asm\"", NULL
241 "MCU 80C51XA", /* Target name */
242 NULL, /* Processor name */
245 FALSE, /* Emit glue around main */
252 "", /* Options with debug */
253 "", /* Options without debug */
256 NULL /* no do_assemble function */
269 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
270 1, 2, 2, 4, 2, 2, 3, 1, 4, 4
272 /* tags for generic pointers */
273 { 0x00, 0x40, 0x60, 0x80 }, /* far, near, xstack, code */
279 NULL, //"ISEG (DATA)",
280 NULL, //"PSEG (PAG,XDATA)",
283 NULL, //"RSEG (DATA)",
285 NULL, //"OSEG (OVR,XDATA)",
288 "XISEG (XDATA)", // initialized xdata
289 "XINIT (CODE)", // a code copy of xiseg
290 "CONST (CODE)", // const_name - const data (code or not)
291 "CABS (ABS,CODE)", // cabs_name - const absolute data (code or not)
292 NULL, // default local map
293 NULL, // default global map
298 -1, // stack grows down
299 0, // bank overhead NUY
300 4, // isr overhead, page zero mode
301 2, // function call overhead, page zero mode
302 0, // reentrant overhead NUY
303 0 // banked overhead NUY
305 /* xa51 has an 16 bit mul */
310 xa51_emitDebuggerSymbol
313 255/3, /* maxCount */
314 3, /* sizeofElement */
315 /* The rest of these costs are bogus. They approximate */
316 /* the behavior of src/SDCCicode.c 1.207 and earlier. */
317 {4,4,4}, /* sizeofMatchJump[] */
318 {0,0,0}, /* sizeofRangeCompare[] */
319 0, /* sizeofSubtract */
320 3, /* sizeofDispatch */
327 _xa51_finaliseOptions,
328 _xa51_setDefaultOptions,
329 xa51_assignRegisters,
332 _xa51_genAssemblerPreamble,
333 _xa51_genAssemblerEnd,
336 NULL, /* genInitStartup */
339 NULL, // process_pragma()
340 NULL, // getMangledFunctionName()
341 NULL, // hasNativeMulFor()
342 hasExtBitOp, /* hasExtBitOp */
343 oclsExpense, /* oclsExpense */
344 TRUE, // use_dw_for_init
345 TRUE, /* little endian */
348 1, /* transform <= to ! > */
349 1, /* transform >= to ! < */
350 1, /* transform != to !(a == b) */
352 FALSE, /* No array initializer support. */
354 NULL, /* no builtin functions */
355 GPOINTER, /* treat unqualified pointers as "generic" pointers */
356 1, /* reset labelKey to 1 */
357 1, /* globals & local static allowed */