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 () {
47 //fprintf (stderr, "Did %d rewind%c for c-line in asm comments\n", rewinds,
48 //rewinds==1 ? '\0' : 's');
51 void xa51_assignRegisters (eBBlock ** ebbs, int count);
53 static int regParmFlg = 0; /* determine if we can register a parameter */
58 asm_addTree (&asm_xa_asm_mapping);
62 _xa51_reset_regparm ()
68 _xa51_regparm (sym_link * l)
71 /* for this processor it is simple
72 can pass only the first parameter in a register */
81 _xa51_parseOptions (int *pargc, char **argv, int *i)
83 /* TODO: allow port-specific command line options to specify
90 _xa51_finaliseOptions (void)
92 port->mem.default_local_map = istack;
93 port->mem.default_globl_map = xdata;
94 if (options.model!=MODEL_PAGE0) {
95 fprintf (stderr, "-mxa51 only supports --model-page0\n");
101 _xa51_setDefaultOptions (void)
104 options.intlong_rent=1;
105 options.float_rent=1;
106 options.stack_loc=0x100;
111 _xa51_getRegName (struct regs *reg)
118 /* Generate interrupt vector table. */
120 _xa51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
125 /* Generate code to copy XINIT to XISEG */
126 static void _xa51_genXINIT (FILE * of) {
127 fprintf (of, "; _xa51_genXINIT() start\n");
128 fprintf (of, " mov r0,#l_XINIT\n");
129 fprintf (of, " beq 00002$\n");
130 fprintf (of, " mov r1,#s_XINIT\n");
131 fprintf (of, " mov r2,#s_XISEG\n");
132 fprintf (of, "00001$: movc r3l,[r1+]\n");
133 fprintf (of, " mov [r2+],r3l\n");
134 fprintf (of, " djnz r0,00001$\n");
135 fprintf (of, "00002$:\n");
136 fprintf (of, "; _xa51_genXINIT() end\n");
140 _xa51_genAssemblerPreamble (FILE * of)
142 symbol *mainExists=newSymbol("main", 0);
145 if ((mainExists=findSymWithLevel(SymbolTab, mainExists))) {
146 fprintf (of, "\t.area GSINIT\t(CODE)\n");
147 fprintf (of, "__interrupt_vect:\n");
148 fprintf (of, "\t.dw\t0x8f00\n");
149 fprintf (of, "\t.dw\t__sdcc_gsinit_startup\n");
151 fprintf (of, "__sdcc_gsinit_startup:\n");
152 fprintf (of, ";\tmov.b\t_SCR,#0x01\t; page zero mode\n");
153 fprintf (of, "\t.db 0x96,0x48,0x40,0x01\n");
154 fprintf (of, "\tmov\tr7,#0x%04x\n", options.stack_loc);
155 fprintf (of, "\tcall\t_external_startup\n");
157 fprintf (of, "\t.area CSEG\t(CODE)\n");
158 fprintf (of, "\tcall\t_main\n");
159 fprintf (of, "\treset\t;main should not return\n");
163 /* dummy linker for now */
167 /* Do CSE estimation */
168 static bool cseCostEstimation (iCode *ic, iCode *pdic)
170 operand *result = IC_RESULT(ic);
171 sym_link *result_type = operandType(result);
173 /* if it is a pointer then return ok for now */
174 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
176 /* if bitwise | add & subtract then no since xa51 is pretty good at it
177 so we will cse only if they are local (i.e. both ic & pdic belong to
178 the same basic block */
179 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
180 /* then if they are the same Basic block then ok */
181 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
185 /* for others it is cheaper to do the cse */
189 /** $1 is always the basename.
190 $2 is always the output file.
192 $l is the list of extra options that should be there somewhere...
193 MUST be terminated with a NULL.
195 static const char *_linkCmd[] =
197 "xa_link", "", "$1", NULL
200 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
201 static const char *_asmCmd[] =
203 "xa_rasm", "$l", "$3", "$1.asm", NULL
211 "MCU 80C51XA", /* Target name */
212 NULL, /* Processor name */
214 FALSE, /* Emit glue around main */
221 "", /* Options with debug */
222 "", /* Options without debug */
225 NULL /* no do_assemble function */
237 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
238 1, 2, 2, 4, 2, 2, 3, 1, 4, 4
245 NULL, //"ISEG (DATA)",
248 NULL, //"RSEG (DATA)",
250 NULL, //"OSEG (OVR,XDATA)",
253 "XISEG (XDATA)", // initialized xdata
254 "XINIT (CODE)", // a code copy of xiseg
255 NULL, // default local map
256 NULL, // default global map
260 -1, // stack grows down
261 0, // bank overhead NUY
262 4, // isr overhead, page zero mode
263 2, // function call overhead, page zero mode
264 0, // reentrant overhead NUY
265 0 // banked overhead NUY
267 /* xa51 has an 16 bit mul */
275 _xa51_finaliseOptions,
276 _xa51_setDefaultOptions,
277 xa51_assignRegisters,
280 _xa51_genAssemblerPreamble,
281 _xa51_genAssemblerEnd,
286 NULL, // process_pragma()
287 NULL, // getMangledFunctionName()
288 NULL, // hasNativeMulFor()
289 TRUE, // use_dw_for_init
292 1, /* transform <= to ! > */
293 1, /* transform >= to ! < */
294 1, /* transform != to !(a == b) */
296 FALSE, /* No array initializer support. */
298 NULL, /* no builtin functions */
299 GPOINTER, /* treat unqualified pointers as "generic" pointers */
300 1, /* reset labelKey to 1 */
301 1, /* globals & local static allowed */