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[] =
46 static builtins __ds390_builtins[] = {
47 { "__builtin_memcpy_x2x","v",3,{"cx*","cx*","i"}}, /* void __builtin_memcpy_x2x (xdata char *,xdata char *,int) */
48 { "__builtin_memcpy_c2x","v",3,{"cx*","cp*","i"}}, /* void __builtin_memcpy_c2x (xdata char *,code char *,int) */
49 { NULL , NULL,0, {NULL}} /* mark end of table */
51 void ds390_assignRegisters (eBBlock ** ebbs, int count);
53 static int regParmFlg = 0; /* determine if we can register a parameter */
58 asm_addTree (&asm_asxxxx_mapping);
62 _ds390_reset_regparm ()
68 _ds390_regparm (sym_link * l)
70 /* for this processor it is simple
71 can pass only the first parameter in a register */
80 _ds390_parseOptions (int *pargc, char **argv, int *i)
82 /* TODO: allow port-specific command line options to specify
89 _ds390_finaliseOptions (void)
91 /* Hack-o-matic: if we are using the flat24 model,
92 * adjust pointer sizes.
94 if (options.model != MODEL_FLAT24) {
96 "*** warning: ds390 port small and large model experimental.\n");
97 if (options.model == MODEL_LARGE)
99 port->mem.default_local_map = xdata;
100 port->mem.default_globl_map = xdata;
104 port->mem.default_local_map = data;
105 port->mem.default_globl_map = data;
109 port->s.fptr_size = 3;
110 port->s.gptr_size = 4;
112 port->stack.isr_overhead += 2; /* Will save dpx on ISR entry. */
114 port->stack.call_overhead += 2; /* This acounts for the extra byte
115 * of return addres on the stack.
116 * but is ugly. There must be a
120 port->mem.default_local_map = xdata;
121 port->mem.default_globl_map = xdata;
123 if (!options.stack10bit)
126 "*** error: ds390 port only supports the 10 bit stack mode.\n");
128 if (!options.stack_loc) options.stack_loc = 0x400000;
131 /* generate native code 16*16 mul/div */
132 if (options.useAccelerator)
133 port->support.muldiv=2;
135 port->support.muldiv=1;
137 /* Fixup the memory map for the stack; it is now in
138 * far space and requires a FPOINTER to access it.
141 istack->ptrType = FPOINTER;
146 _ds390_setDefaultOptions (void)
148 options.model=MODEL_FLAT24;
149 options.stack10bit=1;
153 _ds390_getRegName (struct regs *reg)
161 _ds390_genAssemblerPreamble (FILE * of)
163 if (options.model == MODEL_FLAT24)
164 fputs (".flat24 on\t\t; 24 bit flat addressing\n", of);
166 fputs ("dpx = 0x93\t\t; dpx register unknown to assembler\n", of);
167 fputs ("dps = 0x86\t\t; dps register unknown to assembler\n", of);
168 fputs ("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of);
169 fputs ("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of);
170 fputs ("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of);
171 fputs ("ap = 0x9C\t\t; ap register unknown to assembler\n", of);
172 fputs ("mcnt0 = 0xD1\t\t; mcnt0 register unknown to assembler\n", of);
173 fputs ("mcnt1 = 0xD2\t\t; mcnt1 register unknown to assembler\n", of);
174 fputs ("ma = 0xD3\t\t; ma register unknown to assembler\n", of);
175 fputs ("mb = 0xD4\t\t; mb register unknown to assembler\n", of);
176 fputs ("mc = 0xD5\t\t; mc register unknown to assembler\n", of);
177 fputs ("F1 = 0xD1\t\t; F1 user flag unknown to assembler\n", of);
178 fputs ("esp = 0x9B\t\t; ESP user flag unknown to assembler\n", of);
181 /* Generate interrupt vector table. */
183 _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
187 if (options.model != MODEL_FLAT24)
189 /* Let the default code handle it. */
193 fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n");
195 /* now for the other interrupts */
196 for (i = 0; i < maxInterrupts; i++)
200 fprintf (of, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
204 fprintf (of, "\treti\n\t.ds\t7\n");
211 /* Do CSE estimation */
212 static bool cseCostEstimation (iCode *ic, iCode *pdic)
214 operand *result = IC_RESULT(ic);
215 //operand *right = IC_RIGHT(ic);
216 //operand *left = IC_LEFT(ic);
217 sym_link *result_type = operandType(result);
218 //sym_link *right_type = (right ? operandType(right) : 0);
219 //sym_link *left_type = (left ? operandType(left) : 0);
221 /* if it is a pointer then return ok for now */
222 if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
224 /* if bitwise | add & subtract then no since mcs51 is pretty good at it
225 so we will cse only if they are local (i.e. both ic & pdic belong to
226 the same basic block */
227 if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
228 /* then if they are the same Basic block then ok */
229 if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
233 /* for others it is cheaper to do the cse */
236 /** $1 is always the basename.
237 $2 is always the output file.
239 $l is the list of extra options that should be there somewhere...
240 MUST be terminated with a NULL.
242 static const char *_linkCmd[] =
244 "aslink", "-nf", "$1", NULL
247 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */ static const char *_asmCmd[] =
249 "asx8051", "$l", "$3", "$1.asm", NULL
257 "DS80C390", /* Target name */
259 TRUE, /* Emit glue around main */
260 MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
266 "-plosgffc", /* Options with debug */
267 "-plosgff", /* Options without debug */
281 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
282 1, 2, 2, 4, 1, 2, 3, 1, 4, 4
304 /* ds390 has an 16 bit mul & div */
311 _ds390_finaliseOptions,
312 _ds390_setDefaultOptions,
313 ds390_assignRegisters,
316 _ds390_genAssemblerPreamble,
318 _ds390_reset_regparm,
326 1, /* transform <= to ! > */
327 1, /* transform >= to ! < */
328 1, /* transform != to !(a == b) */
330 TRUE, /* we support array initializers. */
332 __ds390_builtins, /* table of builtin functions */