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 bool _mcs51_parseOptions(int *pargc, char **argv, int *i)
49 /* TODO: allow port-specific command line options to specify
55 static void _mcs51_finaliseOptions(void)
57 /* Hack-o-matic: if we are using the flat24 model,
58 * adjust pointer sizes.
60 if (options.model == MODEL_FLAT24)
62 port->s.fptr_size = 3;
63 port->s.gptr_size = 4;
64 port->stack.isr_overhead++; /* Will save dpx on ISR entry. */
66 port->stack.call_overhead++; /* This acounts for the extra byte
67 * of return addres on the stack.
68 * but is ugly. There must be a
77 port->mem.default_local_map = xdata;
78 port->mem.default_globl_map = xdata;
80 port->mem.default_local_map = data;
81 port->mem.default_globl_map = data;
84 if (options.stack10bit)
86 if (options.model != MODEL_FLAT24)
89 "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
90 fprintf(stderr, "\t10 bit stack mode disabled.\n");
91 options.stack10bit = 0;
95 /* Fixup the memory map for the stack; it is now in
96 * far space and requires a FPOINTER to access it.
99 istack->ptrType = FPOINTER;
104 static void _mcs51_setDefaultOptions(void)
108 static const char *_mcs51_getRegName(struct regs *reg)
115 static void _mcs51_genAssemblerPreamble(FILE *of)
117 if (options.model == MODEL_FLAT24)
119 fputs(".flat24 on\t\t; 24 bit flat addressing\n", of);
120 fputs("dpx = 0x93\t\t; dpx register unknown to assembler\n", of);
121 fputs("dps = 0x86\t\t; dps register unknown to assembler\n", of);
122 fputs("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of);
123 fputs("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of);
124 fputs("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of);
128 /* Generate interrupt vector table. */
129 static int _mcs51_genIVT(FILE *of, symbol **interrupts, int maxInterrupts)
133 if (options.model != MODEL_FLAT24)
135 /* Let the default code handle it. */
139 fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n");
141 /* now for the other interrupts */
142 for (i = 0; i < maxInterrupts; i++)
146 fprintf(of, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
150 fprintf(of, "\treti\n\t.ds\t7\n");
157 /** $1 is always the basename.
158 $2 is always the output file.
160 $l is the list of extra options that should be there somewhere...
161 MUST be terminated with a NULL.
163 static const char *_linkCmd[] = {
164 "aslink", "-nf", "$1", NULL
167 static const char *_asmCmd[] = {
168 "asx8051", "-plosgffc", "$1.asm", NULL
174 "MCU 8051", /* Target name */
176 TRUE, /* Emit glue around main */
180 "-plosgffc", /* Options with debug */
181 "-plosgff", /* Options without debug */
190 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
191 1, 1, 2, 4, 1, 2, 3, 1, 4, 4
211 /* mcs51 has an 8 bit mul */
217 _mcs51_finaliseOptions,
218 _mcs51_setDefaultOptions,
219 mcs51_assignRegisters,
222 _mcs51_genAssemblerPreamble,