+2004-03-17 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCCglue.c (emitMaps): allow public sfr variables
+ * src/SDCCglue.c (initialComments): include compiler build date
+ with compiler version and put the timestamp of the generated
+ assembly file on a serperate line to be less confusing.
+ * src/port.h: added genInitStartup hook
+ * src/avr/main.c,
+ * src/ds390/main.c,
+ * src/hc08/main.c,
+ * src/pic/main.c,
+ * src/pic16/main.c,
+ * src/xa51/main.c,
+ * src/z80/main.c: genInitStartup initialize as NULL (default to
+ historical behaviour)
+ * src/SDCCglue.c (glue): _sdcc_gsinit_startup is now port specific.
+ * src/mcs51/main.c: (_mcs51_genInitStartup, _mcs51_genExtraAreas,
+ _mcs51_genXINIT, _mcs51_genRAMCLEAR): link initialization code from the
+ library instead of hard coding it into the compiler.
+ * support/regression/ports/mcs51-stack-auto/spec.mk,
+ * src/SDCCmain.c (linkEdit): added mcs51.lib to the link libraries
+ * device/lib/mcs51/Makefile,
+ * device/lib/small/Makefile,
+ * device/lib/large/Makefile,
+ * device/lib/mcs51/crtpagesfr.asm,
+ * device/lib/mcs51/crtstart.asm,
+ * device/lib/mcs51/crtxclear.asm,
+ * device/lib/mcs51/crtxinit.asm,
+ * device/lib/mcs51/crtclear.asm,
+ * device/lib/mcs51/crtxstack.asm: move most of the mcs51 C runtime
+ startup/initialization out of src/SDCCglue.c and src/mcs51/main.c
+ and into user configurable files.
+ * device/lib/clean.mk: clean mcs51 directory too
+ * support/regression/tests/longlit.c: added static to T1 declaration
+ * doc/sdccman.lyx: documented _PAGESFR sfr for customizing pdata
+ accesses in the initialization code
+
2004-03-14 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
* device/include/mc68hc908qy.h: corrected declarations of FLBPR and
for model in $(MODELS); do \
find $$model -maxdepth 1 -type f ! -name Makefile -exec rm {} \; ; \
done
+ make -C mcs51 clean
make -C ds390 clean
make -C z80 clean
make -C gbz80 clean
# Dummy Makefile to get around CVS
all:
+ make -C ../mcs51 all
+ cp ../mcs51/*.rel ../mcs51/*.lib .
touch dummy.lib
touch dummy.rel
clean:
+ rm *.rel *.lib
--- /dev/null
+
+TOPDIR = ../../..
+
+SAS = $(TOPDIR)/bin/asx8051
+SCC = $(TOPDIR)/bin/sdcc
+
+OBJ = crtstart.rel crtxinit.rel crtxclear.rel crtclear.rel crtxstack.rel \
+ crtpagesfr.rel
+
+LIB = mcs51.lib
+
+CC = $(SCC)
+AS = $(SAS)
+ASFLAGS = -plosgff
+
+CFLAGS = -I../../include -I.
+
+all: $(LIB)
+
+$(LIB): $(OBJ) Makefile
+ rm -f $(LIB)
+ for i in $(OBJ); do echo $$i >> $(LIB); done
+
+%.rel: %.c
+ $(CC) $(CFLAGS) -c $<
+
+%.rel: %.asm
+ $(AS) $(ASFLAGS) $<
+
+clean:
+ rm -f *.rel *.sym *.lst *~ $(CLEANSPEC) *.dump* *.lib
--- /dev/null
+; /*-------------------------------------------------------------------------
+;
+; crtclear.asm :- C run-time: clear DATA/IDATA
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;
+; In other words, you are welcome to use, share and improve this program.
+; You are forbidden to forbid anyone else to use, share and improve
+; what you give them. Help stamp out software-hoarding!
+; -------------------------------------------------------------------------*/
+
+ .area CSEG (CODE)
+ .area GSINIT0 (CODE)
+ .area GSINIT1 (CODE)
+ .area GSINIT2 (CODE)
+ .area GSINIT3 (CODE)
+ .area GSINIT4 (CODE)
+ .area GSINIT5 (CODE)
+ .area GSINIT (CODE)
+ .area GSFINAL (CODE)
+
+ .area GSINIT4 (CODE)
+
+__mcs51_genRAMCLEAR::
+ clr a
+ mov r0,a
+00005$: mov @r0,a
+ djnz r0,00005$
+; _mcs51_genRAMCLEAR() end
--- /dev/null
+; /*-------------------------------------------------------------------------
+;
+; crtpagesfr.asm :- C run-time: define page sfr for movx @r0/r1 instructions
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;
+; In other words, you are welcome to use, share and improve this program.
+; You are forbidden to forbid anyone else to use, share and improve
+; what you give them. Help stamp out software-hoarding!
+; -------------------------------------------------------------------------*/
+
+__PAGESFR == 0xa0 ; 0xa0 is P2 on the original 8051
--- /dev/null
+; /*-------------------------------------------------------------------------
+;
+; crtstart.asm :- C run-time: startup
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;
+; In other words, you are welcome to use, share and improve this program.
+; You are forbidden to forbid anyone else to use, share and improve
+; what you give them. Help stamp out software-hoarding!
+; -------------------------------------------------------------------------*/
+
+ .area CSEG (CODE)
+ .area GSINIT0 (CODE)
+ .area GSINIT1 (CODE)
+ .area GSINIT2 (CODE)
+ .area GSINIT3 (CODE)
+ .area GSINIT4 (CODE)
+ .area GSINIT5 (CODE)
+ .area GSINIT (CODE)
+ .area GSFINAL (CODE)
+
+ .globl __start__stack
+
+ .area GSINIT0 (CODE)
+
+__sdcc_gsinit_startup::
+ mov sp,#__start__stack - 1
+
+ .area GSINIT2 (CODE)
+
+ lcall __sdcc_external_startup
+ mov a,dpl
+ jz __sdcc_init_data
+ ljmp __sdcc_program_startup
+__sdcc_init_data:
--- /dev/null
+; /*-------------------------------------------------------------------------
+;
+; crtxclear.asm :- C run-time: clear XSEG
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;
+; In other words, you are welcome to use, share and improve this program.
+; You are forbidden to forbid anyone else to use, share and improve
+; what you give them. Help stamp out software-hoarding!
+; -------------------------------------------------------------------------*/
+
+ .area CSEG (CODE)
+ .area GSINIT0 (CODE)
+ .area GSINIT1 (CODE)
+ .area GSINIT2 (CODE)
+ .area GSINIT3 (CODE)
+ .area GSINIT4 (CODE)
+ .area GSINIT5 (CODE)
+ .area GSINIT (CODE)
+ .area GSFINAL (CODE)
+
+ .area GSINIT4 (CODE)
+
+__mcs51_genXRAMCLEAR::
+ mov r0,#l_XSEG
+ mov a,r0
+ orl a,#(l_XSEG >> 8)
+ jz 00005$
+ mov r1,#((l_XSEG + 255) >> 8)
+ mov dptr,#s_XSEG
+ clr a
+00004$: movx @dptr,a
+ inc dptr
+ djnz r0,00004$
+ djnz r1,00004$
+00005$:
+
--- /dev/null
+; /*-------------------------------------------------------------------------
+;
+; crtxinit.asm :- C run-time: copy XINIT to XISEG
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;
+; In other words, you are welcome to use, share and improve this program.
+; You are forbidden to forbid anyone else to use, share and improve
+; what you give them. Help stamp out software-hoarding!
+; -------------------------------------------------------------------------*/
+
+ .area CSEG (CODE)
+ .area GSINIT0 (CODE)
+ .area GSINIT1 (CODE)
+ .area GSINIT2 (CODE)
+ .area GSINIT3 (CODE)
+ .area GSINIT4 (CODE)
+ .area GSINIT5 (CODE)
+ .area GSINIT (CODE)
+ .area GSFINAL (CODE)
+
+ .area GSINIT3 (CODE)
+
+__mcs51_genXINIT::
+ mov r1,#l_XINIT
+ mov a,r1
+ orl a,#(l_XINIT >> 8)
+ jz 00003$
+ mov r2,#((l_XINIT+255) >> 8)
+ mov dptr,#s_XINIT
+ mov r0,#s_XISEG
+ mov __PAGESFR,#(s_XISEG >> 8)
+00001$: clr a
+ movc a,@a+dptr
+ movx @r0,a
+ inc dptr
+ inc r0
+ cjne r0,#0,00002$
+ inc __PAGESFR
+00002$: djnz r1,00001$
+ djnz r2,00001$
+ mov __PAGESFR,#0xFF
+00003$:
+
\ No newline at end of file
--- /dev/null
+; /*-------------------------------------------------------------------------
+;
+; crtxstack.asm :- C run-time: setup xstack
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+;
+; In other words, you are welcome to use, share and improve this program.
+; You are forbidden to forbid anyone else to use, share and improve
+; what you give them. Help stamp out software-hoarding!
+; -------------------------------------------------------------------------*/
+
+ .area CSEG (CODE)
+ .area GSINIT0 (CODE)
+ .area GSINIT1 (CODE)
+ .area GSINIT2 (CODE)
+ .area GSINIT3 (CODE)
+ .area GSINIT4 (CODE)
+ .area GSINIT5 (CODE)
+ .area GSINIT (CODE)
+ .area GSFINAL (CODE)
+
+ .globl __start__xstack
+ .globl __PAGESFR
+
+ .area GSINIT1 (CODE)
+
+__sdcc_init_xstack::
+
+; Need to initialize in GSINIT1 in case the user's __sdcc_external_startup
+; uses the xstack.
+
+ mov __PAGESFR,#(__start__xstack >> 8)
+ mov _spx,#__start__xstack
+
+ .area GSINIT5 (CODE)
+
+; Need to initialize in GSINIT5 because __mcs51_genXINIT modifies __PAGESFR
+; and __mcs51_genRAMCLEAR modifies _spx.
+
+ mov __PAGESFR,#(__start__xstack >> 8)
+ mov _spx,#__start__xstack
# Dummy Makefile to get around CVS
all:
+ make -C ../mcs51 all
+ cp ../mcs51/*.rel ../mcs51/*.lib .
touch dummy.lib
touch dummy.rel
clean:
+ rm *.rel *.lib
\emph default
is where the chip designers decided to put it.
Needless to say that they didn't agree on a common name either.
- As pdata addressing is used in the startup code for the initialization
- of xdata variables a separate startup code should be used as described
- in section
+ So that the startup code can correctly initialize xdata variables, you
+ should define an sfr with the name _PAGESFR at the appropriate location
+ if the default, port P2, is not used for this.
+ Some examples are:
+\layout Verse
+
+
+\family typewriter
+sfr at 0x92 _PAGESFR; /* Cypress EZ-USB family */
+\layout Verse
+
+
+\family typewriter
+sfr at 0xaf _PAGESFR; /* some Silicon Labs (Cygnal) chips */
+\layout Verse
+
+
+\family typewriter
+sfr at 0xaa _PAGESFR; /* some Silicon Labs (Cygnal) chips */
+\layout Standard
+
+For more exotic implementations further customizations may be needed.
+ See section
\begin_inset LatexCommand \ref{sub:Startup-Code}
\end_inset
-.
+ for other possibilities.
\layout Subsection
Other Features available by SFR
tfprintf (oFile, "\t.byte %s,%s\n", aopLiteral (val, 1), aopLiteral (val, 0));
break;
case 3: // how about '390??
+ fprintf (oFile, "; generic printIvalPtr\n");
if (port->little_endian)
{
- fprintf (oFile, "\t.byte %s,%s,%s\n",
- aopLiteral (val, 0), aopLiteral (val, 1), aopLiteral (val, 2));
+ fprintf (oFile, "\t.byte %s,%s",
+ aopLiteral (val, 0), aopLiteral (val, 1));
}
else
{
- fprintf (oFile, "\t.byte %s,%s,%s\n",
- aopLiteral (val, 2), aopLiteral (val, 1), aopLiteral (val, 0));
+ fprintf (oFile, "\t.byte %s,%s",
+ aopLiteral (val, 1), aopLiteral (val, 0));
}
+ if (IS_GENPTR (val->type))
+ fprintf (oFile, ",%s\n", aopLiteral (val, 2));
+ else if (IS_PTR (val->type))
+ fprintf (oFile, ",#%x\n", pointerTypeToGPByte (DCL_TYPE (val->type), NULL, NULL));
+ else
+ fprintf (oFile, ",%s\n", aopLiteral (val, 2));
}
return;
}
void
emitMaps (void)
{
+ int publicsfr = TARGET_IS_MCS51; /* Ideally, this should be true for all */
+ /* ports but let's be conservative - EEP */
+
inInitMode++;
/* no special considerations for the following
data, idata & bit & xdata */
if (port->genXINIT) {
emitRegularMap (xidata, TRUE, TRUE);
}
- emitRegularMap (sfr, FALSE, FALSE);
- emitRegularMap (sfrbit, FALSE, FALSE);
+ emitRegularMap (sfr, publicsfr, FALSE);
+ emitRegularMap (sfrbit, publicsfr, FALSE);
emitRegularMap (home, TRUE, FALSE);
emitRegularMap (code, TRUE, FALSE);
time_t t;
time (&t);
fprintf (afile, "%s", iComments1);
- fprintf (afile, "; Version " SDCC_VERSION_STR " %s\n", asctime (localtime (&t)));
+ fprintf (afile, "; Version " SDCC_VERSION_STR " (%s)\n", __DATE__);
+ fprintf (afile, "; This file generated %s", asctime (localtime (&t)));
fprintf (afile, "%s", iComments2);
}
if (mainf && IFFUNC_HASBODY(mainf->type))
{
- fprintf (asmFile, "__sdcc_gsinit_startup:\n");
- /* if external stack is specified then the
- higher order byte of the xdatalocation is
- going into P2 and the lower order going into
- spx */
- if (options.useXstack)
- {
- fprintf (asmFile, "\tmov\tP2,#0x%02x\n",
- (((unsigned int) options.xdata_loc) >> 8) & 0xff);
- fprintf (asmFile, "\tmov\t_spx,#0x%02x\n",
- (unsigned int) options.xdata_loc & 0xff);
+ if (port->genInitStartup)
+ {
+ port->genInitStartup(asmFile);
}
+ else
+ {
+ fprintf (asmFile, "__sdcc_gsinit_startup:\n");
+ /* if external stack is specified then the
+ higher order byte of the xdatalocation is
+ going into P2 and the lower order going into
+ spx */
+ if (options.useXstack)
+ {
+ fprintf (asmFile, "\tmov\tP2,#0x%02x\n",
+ (((unsigned int) options.xdata_loc) >> 8) & 0xff);
+ fprintf (asmFile, "\tmov\t_spx,#0x%02x\n",
+ (unsigned int) options.xdata_loc & 0xff);
+ }
- // This should probably be a port option, but I'm being lazy.
- // on the 400, the firmware boot loader gives us a valid stack
- // (see '400 data sheet pg. 85 (TINI400 ROM Initialization code)
- if (!TARGET_IS_DS400)
- {
- /* initialise the stack pointer. JCF: aslink takes care of the location */
- fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n"); /* MOF */
- }
+ // This should probably be a port option, but I'm being lazy.
+ // on the 400, the firmware boot loader gives us a valid stack
+ // (see '400 data sheet pg. 85 (TINI400 ROM Initialization code)
+ if (!TARGET_IS_DS400)
+ {
+ /* initialise the stack pointer. JCF: aslink takes care of the location */
+ fprintf (asmFile, "\tmov\tsp,#__start__stack - 1\n"); /* MOF */
+ }
- fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
- fprintf (asmFile, "\tmov\ta,dpl\n");
- fprintf (asmFile, "\tjz\t__sdcc_init_data\n");
- fprintf (asmFile, "\tljmp\t__sdcc_program_startup\n");
- fprintf (asmFile, "__sdcc_init_data:\n");
+ fprintf (asmFile, "\tlcall\t__sdcc_external_startup\n");
+ fprintf (asmFile, "\tmov\ta,dpl\n");
+ fprintf (asmFile, "\tjz\t__sdcc_init_data\n");
+ fprintf (asmFile, "\tljmp\t__sdcc_program_startup\n");
+ fprintf (asmFile, "__sdcc_init_data:\n");
- // if the port can copy the XINIT segment to XISEG
- if (port->genXINIT) {
- port->genXINIT(asmFile);
- }
+ // if the port can copy the XINIT segment to XISEG
+ if (port->genXINIT)
+ {
+ port->genXINIT(asmFile);
+ }
+ }
}
copyFile (asmFile, statsg->oFile);
}
#endif
#endif
- if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80
+ if (TARGET_IS_MCS51)
+ {
+ fprintf (lnkfile, "-l mcs51\n");
+ }
+ if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80
|| TARGET_IS_HC08)) /*Not for the z80, gbz80*/
{ /*Why the z80 port is not using the standard libraries?*/
fprintf (lnkfile, "-l %s\n", STD_LIB);
NULL, /* no genAssemblerEnd */
_avr_genIVT,
NULL, // _avr_genXINIT
+ NULL, /* genInitStartup */
_avr_reset_regparm,
_avr_regparm,
NULL,
NULL, /* no genAssemblerEnd */
_ds390_genIVT,
_ds390_genXINIT,
+ NULL, /* genInitStartup */
_ds390_reset_regparm,
_ds390_regparm,
NULL,
_tininative_genAssemblerEnd,
_tininative_genIVT,
NULL,
+ NULL, /* genInitStartup */
_ds390_reset_regparm,
_ds390_regparm,
NULL,
NULL, /* no genAssemblerEnd */
_ds400_genIVT,
_ds390_genXINIT,
+ NULL, /* genInitStartup */
_ds390_reset_regparm,
_ds390_regparm,
NULL,
NULL, /* no genAssemblerEnd */
_hc08_genIVT,
_hc08_genXINIT,
+ NULL, /* genInitStartup */
_hc08_reset_regparm,
_hc08_regparm,
NULL, /* process_pragma */
for (i=0; i < 8 ; i++ )
fprintf (of,"b1_%d = 0x%x \n",i,8+i);
}
+
}
/* Generate interrupt vector table. */
return FALSE;
}
-/* Generate code to clear XSEG and idata memory.
- This clears XSEG, DSEG, BSEG, OSEG, SSEG */
-static void _mcs51_genRAMCLEAR (FILE * of) {
- fprintf (of, "; _mcs51_genRAMCLEAR() start\n");
- fprintf (of, " mov r0,#l_XSEG\n");
- fprintf (of, " mov a,r0\n");
- fprintf (of, " orl a,#(l_XSEG >> 8)\n");
- fprintf (of, " jz 00005$\n");
- fprintf (of, " mov r1,#((l_XSEG + 255) >> 8)\n");
- fprintf (of, " mov dptr,#s_XSEG\n");
- fprintf (of, " clr a\n");
- fprintf (of, "00004$: movx @dptr,a\n");
- fprintf (of, " inc dptr\n");
- fprintf (of, " djnz r0,00004$\n");
- fprintf (of, " djnz r1,00004$\n");
- /* r0 is zero now. Clearing 256 byte assuming 128 byte devices don't mind */
- fprintf (of, "00005$: mov @r0,a\n");
- fprintf (of, " djnz r0,00005$\n");
- fprintf (of, "; _mcs51_genRAMCLEAR() end\n");
+static void
+_mcs51_genExtraAreas(FILE *of, bool hasMain)
+{
+ tfprintf (of, "\t!area\n", port->mem.code_name);
+ tfprintf (of, "\t!area\n", "GSINIT0 (CODE)");
+ tfprintf (of, "\t!area\n", "GSINIT1 (CODE)");
+ tfprintf (of, "\t!area\n", "GSINIT2 (CODE)");
+ tfprintf (of, "\t!area\n", "GSINIT3 (CODE)");
+ tfprintf (of, "\t!area\n", "GSINIT4 (CODE)");
+ tfprintf (of, "\t!area\n", "GSINIT5 (CODE)");
+}
+
+static void
+_mcs51_genInitStartup (FILE *of)
+{
+ tfprintf (of, "\t!global\n", "__sdcc_gsinit_startup");
+ tfprintf (of, "\t!global\n", "__sdcc_program_startup");
+ tfprintf (of, "\t!global\n", "__start__stack");
+
+ if (options.useXstack)
+ {
+ tfprintf (of, "\t!global\n", "__sdcc_init_xstack");
+ tfprintf (of, "\t!global\n", "__start__xstack");
+ fprintf (of, "__start__xstack = 0x%04x", options.xdata_loc);
+ }
+
+ // if the port can copy the XINIT segment to XISEG
+ if (port->genXINIT)
+ {
+ port->genXINIT(of);
+ }
+
+ if (!getenv("SDCC_NOGENRAMCLEAR"))
+ tfprintf (of, "\t!global\n", "__mcs51_genRAMCLEAR");
}
+
/* Generate code to copy XINIT to XISEG */
static void _mcs51_genXINIT (FILE * of) {
- fprintf (of, "; _mcs51_genXINIT() start\n");
- fprintf (of, " mov r1,#l_XINIT\n");
- fprintf (of, " mov a,r1\n");
- fprintf (of, " orl a,#(l_XINIT >> 8)\n");
- fprintf (of, " jz 00003$\n");
- fprintf (of, " mov r2,#((l_XINIT+255) >> 8)\n");
- fprintf (of, " mov dptr,#s_XINIT\n");
- fprintf (of, " mov r0,#s_XISEG\n");
- fprintf (of, " mov p2,#(s_XISEG >> 8)\n");
- fprintf (of, "00001$: clr a\n");
- fprintf (of, " movc a,@a+dptr\n");
- fprintf (of, " movx @r0,a\n");
- fprintf (of, " inc dptr\n");
- fprintf (of, " inc r0\n");
- fprintf (of, " cjne r0,#0,00002$\n");
- fprintf (of, " inc p2\n");
- fprintf (of, "00002$: djnz r1,00001$\n");
- fprintf (of, " djnz r2,00001$\n");
- fprintf (of, " mov p2,#0xFF\n");
- fprintf (of, "00003$:\n");
- fprintf (of, "; _mcs51_genXINIT() end\n");
+ tfprintf (of, "\t!global\n", "__mcs51_genXINIT");
- if (!getenv("SDCC_NOGENRAMCLEAR")) _mcs51_genRAMCLEAR (of);
+ if (!getenv("SDCC_NOGENRAMCLEAR"))
+ tfprintf (of, "\t!global\n", "__mcs51_genXRAMCLEAR");
}
NULL,
1
},
- { NULL, NULL },
+ { _mcs51_genExtraAreas, NULL },
{
+1, 0, 4, 1, 1, 0
},
NULL, /* no genAssemblerEnd */
_mcs51_genIVT,
_mcs51_genXINIT,
+ _mcs51_genInitStartup,
_mcs51_reset_regparm,
_mcs51_regparm,
NULL,
NULL, /* no genAssemblerEnd */
_pic14_genIVT,
NULL, // _pic14_genXINIT
+ NULL, /* genInitStartup */
_pic14_reset_regparm,
_pic14_regparm,
_process_pragma, /* process a pragma */
NULL, /* no genAssemblerEnd */
_pic16_genIVT,
NULL, // _pic16_genXINIT
+ NULL, /* genInitStartup */
_pic16_reset_regparm,
_pic16_regparm,
_process_pragma, /* process a pragma */
int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
void (*genXINIT) (FILE * of);
+
+ /* Write port specific startup code */
+ void (*genInitStartup) (FILE * of);
/* parameter passing in register related functions */
void (*reset_regparms) (); /* reset the register count */
_xa51_genAssemblerEnd,
_xa51_genIVT,
_xa51_genXINIT,
+ NULL, /* genInitStartup */
_xa51_reset_regparm,
_xa51_regparm,
NULL, // process_pragma()
NULL, /* no genAssemblerEnd */
0, /* no local IVT generation code */
0, /* no genXINIT code */
+ NULL, /* genInitStartup */
_reset_regparm,
_reg_parm,
_process_pragma,
NULL, /* no genAssemblerEnd */
0, /* no local IVT generation code */
0, /* no genXINIT code */
+ NULL, /* genInitStartup */
_reset_regparm,
_reg_parm,
_process_pragma,
LIBDIR = gen/$(PORT)/lib
LIBSDCCFLAGS+=--stack-auto --int-long-reent --float-reent
-SDCCFLAGS +=$(LIBSDCCFLAGS) --nostdlib -L$(LIBDIR) -llibsdcc -llibint -lliblong -llibfloat
+SDCCFLAGS +=$(LIBSDCCFLAGS) --nostdlib -L$(LIBDIR) -llibsdcc -llibint \
+ -lliblong -llibfloat -lmcs51
# copy support.c
$(PORTS_DIR)/$(PORT)/%.c: $(PORTS_DIR)/mcs51/%.c
.PHONY: lib-files
lib-files:
+ make -C $(LIBSRCDIR)/mcs51 all
+ cp $(LIBSRCDIR)/mcs51/*.rel $(LIBSRCDIR)/mcs51/mcs51.lib $(LIBDIR)
echo $(MODULES) | tr ' ' '\n' > $(LIBDIR)/libsdcc.lib
touch $(LIBDIR)/libfloat.lib $(LIBDIR)/libint.lib $(LIBDIR)/liblong.lib
#define T1_RELOAD_VALUE -(2*OSCILLATOR)/(32*12*BAUD)
-unsigned char T1=T1_RELOAD_VALUE;
+static unsigned char T1=T1_RELOAD_VALUE;
void test (void) {
ASSERT(T1==0xfd);