2 mcs51 specific general functions.
4 Note that mlh prepended _mcs51_ 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 *_mcs51_keywords[] = {
45 void mcs51_assignRegisters (eBBlock **ebbs, int count);
47 static int regParmFlg = 0; /* determine if we can register a parameter */
49 static void _mcs51_init(void)
51 asm_addTree(&asm_asxxxx_mapping);
54 static void _mcs51_reset_regparm()
59 static int _mcs51_regparm( sym_link *l)
61 /* for this processor it is simple
62 can pass only the first parameter in a register */
70 static bool _mcs51_parseOptions(int *pargc, char **argv, int *i)
72 /* TODO: allow port-specific command line options to specify
78 static void _mcs51_finaliseOptions(void)
80 /* Hack-o-matic: if we are using the flat24 model,
81 * adjust pointer sizes.
83 if (options.model == MODEL_FLAT24)
86 fprintf(stderr, "*** WARNING: you should use the '-mds390' option "
87 "for DS80C390 support. This code generator is "
88 "badly out of date and probably broken.\n");
90 port->s.fptr_size = 3;
91 port->s.gptr_size = 4;
92 port->stack.isr_overhead++; /* Will save dpx on ISR entry. */
94 port->stack.call_overhead++; /* This acounts for the extra byte
95 * of return addres on the stack.
96 * but is ugly. There must be a
100 fReturn = fReturn390;
104 if (options.model == MODEL_LARGE) {
105 port->mem.default_local_map = xdata;
106 port->mem.default_globl_map = xdata;
108 port->mem.default_local_map = data;
109 port->mem.default_globl_map = data;
112 if (options.stack10bit)
114 if (options.model != MODEL_FLAT24)
117 "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
118 fprintf(stderr, "\t10 bit stack mode disabled.\n");
119 options.stack10bit = 0;
123 /* Fixup the memory map for the stack; it is now in
124 * far space and requires a FPOINTER to access it.
127 istack->ptrType = FPOINTER;
132 static void _mcs51_setDefaultOptions(void)
136 static const char *_mcs51_getRegName(struct regs *reg)
143 static void _mcs51_genAssemblerPreamble(FILE *of)
145 if (options.model == MODEL_FLAT24)
147 fputs(".flat24 on\t\t; 24 bit flat addressing\n", of);
148 fputs("dpx = 0x93\t\t; dpx register unknown to assembler\n", of);
149 fputs("dps = 0x86\t\t; dps register unknown to assembler\n", of);
150 fputs("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of);
151 fputs("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of);
152 fputs("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of);
156 /* Generate interrupt vector table. */
157 static int _mcs51_genIVT(FILE *of, symbol **interrupts, int maxInterrupts)
161 if (options.model != MODEL_FLAT24)
163 /* Let the default code handle it. */
167 fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n");
169 /* now for the other interrupts */
170 for (i = 0; i < maxInterrupts; i++)
174 fprintf(of, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
178 fprintf(of, "\treti\n\t.ds\t7\n");
185 /** $1 is always the basename.
186 $2 is always the output file.
188 $l is the list of extra options that should be there somewhere...
189 MUST be terminated with a NULL.
191 static const char *_linkCmd[] = {
192 "aslink", "-nf", "$1", NULL
195 static const char *_asmCmd[] = {
196 "asx8051", "-plosgffc", "$1.asm", NULL
202 "MCU 8051", /* Target name */
204 TRUE, /* Emit glue around main */
205 MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
210 "-plosgffc", /* Options with debug */
211 "-plosgff", /* Options without debug */
223 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
224 1, 1, 2, 4, 1, 2, 3, 1, 4, 4
246 /* mcs51 has an 8 bit mul */
253 _mcs51_finaliseOptions,
254 _mcs51_setDefaultOptions,
255 mcs51_assignRegisters,
258 _mcs51_genAssemblerPreamble,
260 _mcs51_reset_regparm,
266 1, /* transform <= to ! > */
267 1, /* transform >= to ! < */
268 1, /* transform != to !(a == b) */