2 ds390 specific general functions.
4 Note that mlh prepended _ds390_ 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 msc51 */
18 static char *_ds390_keywords[] =
47 void ds390_assignRegisters (eBBlock ** ebbs, int count);
49 static int regParmFlg = 0; /* determine if we can register a parameter */
54 asm_addTree (&asm_asxxxx_mapping);
58 _ds390_reset_regparm ()
64 _ds390_regparm (sym_link * l)
66 /* for this processor it is simple
67 can pass only the first parameter in a register */
76 _ds390_parseOptions (int *pargc, char **argv, int *i)
78 /* TODO: allow port-specific command line options to specify
85 _ds390_finaliseOptions (void)
87 /* Hack-o-matic: if we are using the flat24 model,
88 * adjust pointer sizes.
90 if (options.model != MODEL_FLAT24) {
92 "*** warning: ds390 port small and large model experimental.\n");
93 if (options.model == MODEL_LARGE)
95 port->mem.default_local_map = xdata;
96 port->mem.default_globl_map = xdata;
100 port->mem.default_local_map = data;
101 port->mem.default_globl_map = data;
105 port->s.fptr_size = 3;
106 port->s.gptr_size = 4;
108 port->stack.isr_overhead += 2; /* Will save dpx on ISR entry. */
110 port->stack.call_overhead += 2; /* This acounts for the extra byte
111 * of return addres on the stack.
112 * but is ugly. There must be a
116 port->mem.default_local_map = xdata;
117 port->mem.default_globl_map = xdata;
119 if (!options.stack10bit)
122 "*** error: ds390 port only supports the 10 bit stack mode.\n");
125 /* generate native code 16*16 mul/div */
126 if (options.useAccelerator)
127 port->support.muldiv=2;
129 port->support.muldiv=1;
131 /* Fixup the memory map for the stack; it is now in
132 * far space and requires a FPOINTER to access it.
135 istack->ptrType = FPOINTER;
140 _ds390_setDefaultOptions (void)
142 options.model=MODEL_FLAT24;
143 options.stack10bit=1;
147 _ds390_getRegName (struct regs *reg)
155 _ds390_genAssemblerPreamble (FILE * of)
157 if (options.model == MODEL_FLAT24)
158 fputs (".flat24 on\t\t; 24 bit flat addressing\n", of);
160 fputs ("dpx = 0x93\t\t; dpx register unknown to assembler\n", of);
161 fputs ("dps = 0x86\t\t; dps register unknown to assembler\n", of);
162 fputs ("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of);
163 fputs ("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of);
164 fputs ("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of);
165 fputs ("ap = 0x9C\t\t; ap register unknown to assembler\n", of);
166 fputs ("mcnt0 = 0xD1\t\t; mcnt0 register unknown to assembler\n", of);
167 fputs ("mcnt1 = 0xD2\t\t; mcnt1 register unknown to assembler\n", of);
168 fputs ("ma = 0xD3\t\t; ma register unknown to assembler\n", of);
169 fputs ("mb = 0xD4\t\t; mb register unknown to assembler\n", of);
170 fputs ("mc = 0xD5\t\t; mc register unknown to assembler\n", of);
171 fputs ("F1 = 0xD1\t\t; F1 user flag unknown to assembler\n", of);
174 /* Generate interrupt vector table. */
176 _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
180 if (options.model != MODEL_FLAT24)
182 /* Let the default code handle it. */
186 fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n");
188 /* now for the other interrupts */
189 for (i = 0; i < maxInterrupts; i++)
193 fprintf (of, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
197 fprintf (of, "\treti\n\t.ds\t7\n");
204 /* Do CSE estimation */
205 static bool cseCostEstimation (iCode *ic, iCode *pdic)
207 operand *result = IC_RESULT(ic);
208 operand *right = IC_RIGHT(ic);
209 operand *left = IC_LEFT(ic);
210 sym_link *result_type = operandType(result);
211 sym_link *right_type = (right ? operandType(right) : 0);
212 sym_link *left_type = (left ? operandType(left) : 0);
214 /* if it is a pointer then return ok for now */
215 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
217 /* if bitwise | add & subtract then no since mcs51 is pretty good at it
218 so we will cse only if they are local (i.e. both ic & pdic belong to
219 the same basic block */
220 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
221 /* then if they are the same Basic block then ok */
222 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
226 /* for others it is cheaper to do the cse */
229 /** $1 is always the basename.
230 $2 is always the output file.
232 $l is the list of extra options that should be there somewhere...
233 MUST be terminated with a NULL.
235 static const char *_linkCmd[] =
237 "aslink", "-nf", "$1", NULL
240 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */ static const char *_asmCmd[] =
242 "asx8051", "$l", "$3", "$1.asm", NULL
250 "DS80C390", /* Target name */
252 TRUE, /* Emit glue around main */
253 MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
259 "-plosgffc", /* Options with debug */
260 "-plosgff", /* Options without debug */
274 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
275 1, 2, 2, 4, 1, 2, 3, 1, 4, 4
297 /* ds390 has an 16 bit mul & div */
304 _ds390_finaliseOptions,
305 _ds390_setDefaultOptions,
306 ds390_assignRegisters,
309 _ds390_genAssemblerPreamble,
311 _ds390_reset_regparm,
319 1, /* transform <= to ! > */
320 1, /* transform >= to ! < */
321 1, /* transform != to !(a == b) */
323 TRUE, /* we support array initializers. */