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);
172 fputs ("esp = 0x9B\t\t; ESP user flag unknown to assembler\n", of);
175 /* Generate interrupt vector table. */
177 _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
181 if (options.model != MODEL_FLAT24)
183 /* Let the default code handle it. */
187 fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n");
189 /* now for the other interrupts */
190 for (i = 0; i < maxInterrupts; i++)
194 fprintf (of, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
198 fprintf (of, "\treti\n\t.ds\t7\n");
205 /* Do CSE estimation */
206 static bool cseCostEstimation (iCode *ic, iCode *pdic)
208 operand *result = IC_RESULT(ic);
209 //operand *right = IC_RIGHT(ic);
210 //operand *left = IC_LEFT(ic);
211 sym_link *result_type = operandType(result);
212 //sym_link *right_type = (right ? operandType(right) : 0);
213 //sym_link *left_type = (left ? operandType(left) : 0);
215 /* if it is a pointer then return ok for now */
216 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
218 /* if bitwise | add & subtract then no since mcs51 is pretty good at it
219 so we will cse only if they are local (i.e. both ic & pdic belong to
220 the same basic block */
221 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
222 /* then if they are the same Basic block then ok */
223 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
227 /* for others it is cheaper to do the cse */
230 /** $1 is always the basename.
231 $2 is always the output file.
233 $l is the list of extra options that should be there somewhere...
234 MUST be terminated with a NULL.
236 static const char *_linkCmd[] =
238 "aslink", "-nf", "$1", NULL
241 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */ static const char *_asmCmd[] =
243 "asx8051", "$l", "$3", "$1.asm", NULL
251 "DS80C390", /* Target name */
253 TRUE, /* Emit glue around main */
254 MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
260 "-plosgffc", /* Options with debug */
261 "-plosgff", /* Options without debug */
275 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
276 1, 2, 2, 4, 1, 2, 3, 1, 4, 4
298 /* ds390 has an 16 bit mul & div */
305 _ds390_finaliseOptions,
306 _ds390_setDefaultOptions,
307 ds390_assignRegisters,
310 _ds390_genAssemblerPreamble,
312 _ds390_reset_regparm,
320 1, /* transform <= to ! > */
321 1, /* transform >= to ! < */
322 1, /* transform != to !(a == b) */
324 TRUE, /* we support array initializers. */