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_xa_asm_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;
104 options.stack_loc=0x100;
108 _xa51_getRegName (struct regs *reg)
115 /* Generate interrupt vector table. */
117 _xa51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
122 /* Generate code to copy XINIT to XISEG */
123 static void _xa51_genXINIT (FILE * of) {
124 fprintf (of, "; _xa51_genXINIT() start\n");
125 fprintf (of, " mov r0,#l_XINIT\n");
126 fprintf (of, " beq 00002$\n");
127 fprintf (of, " mov r1,#s_XINIT\n");
128 fprintf (of, " mov r2,#s_XISEG\n");
129 fprintf (of, "00001$: movc r3l,[r1+]\n");
130 fprintf (of, " mov [r2+],r3l\n");
131 fprintf (of, " djnz r0,00001$\n");
132 fprintf (of, "00002$:\n");
133 fprintf (of, "; _xa51_genXINIT() end\n");
137 _xa51_genAssemblerPreamble (FILE * of)
139 fprintf (of, "_errno\tsfr\t0x00; to keep the fp-lib's happy for now\n\n");
140 fprintf (of, "\t.area CSEG\t(CODE)\n");
141 fprintf (of, "__interrupt_vect:\n");
142 fprintf (of, "\t.dw\t0x8f00\n");
143 fprintf (of, "\t.dw\t__sdcc_gsinit_startup\n");
145 fprintf (of, "__sdcc_gsinit_startup:\n");
146 fprintf (of, "\tmov\tr7,#0x%04x\n", options.stack_loc);
147 fprintf (of, "\tcall\t_external_startup\n");
149 fprintf (of, "\tcall\t_main\n");
150 fprintf (of, "\treset\t;main should not return\n");
153 /* dummy linker for now */
157 /* Do CSE estimation */
158 static bool cseCostEstimation (iCode *ic, iCode *pdic)
160 operand *result = IC_RESULT(ic);
161 sym_link *result_type = operandType(result);
163 /* if it is a pointer then return ok for now */
164 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
166 /* if bitwise | add & subtract then no since xa51 is pretty good at it
167 so we will cse only if they are local (i.e. both ic & pdic belong to
168 the same basic block */
169 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
170 /* then if they are the same Basic block then ok */
171 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
175 /* 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
192 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
193 static const char *_asmCmd[] =
195 "xa_asm", "$l", "$3", "$1.xa", NULL
203 "MCU 80C51XA", /* Target name */
205 FALSE, /* Emit glue around main */
212 "", /* Options with debug */
213 "", /* Options without debug */
216 NULL /* no do_assemble function */
228 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
229 1, 2, 2, 4, 2, 2, 3, 1, 4, 4
236 NULL, //"ISEG (DATA)",
239 NULL, //"RSEG (DATA)",
241 NULL, //"OSEG (OVR,XDATA)",
244 "XISEG (XDATA)", // initialized xdata
245 "XINIT (CODE)", // a code copy of xiseg
246 NULL, // default local map
247 NULL, // default global map
251 -1, // stack grows down
252 0, // bank overhead NUY
254 4, // function call overhead
255 0, // reentrant overhead NUY
256 0 // banked overhead NUY
258 /* xa51 has an 16 bit mul */
265 _xa51_finaliseOptions,
266 _xa51_setDefaultOptions,
267 xa51_assignRegisters,
270 _xa51_genAssemblerPreamble,
271 _xa51_genAssemblerEnd,
276 NULL, // process_pragma()
277 NULL, // getMangledFunctionName()
278 NULL, // hasNativeMulFor()
279 TRUE, // use_dw_for_init
282 0, /* transform <= to ! > */
283 0, /* transform >= to ! < */
284 0, /* transform != to !(a == b) */
286 FALSE, /* No array initializer support. */
288 NULL, /* no builtin functions */
289 GPOINTER, /* treat unqualified pointers as "generic" pointers */
290 1, /* reset labelKey to 1 */
291 1, /* globals & local static allowed */