- 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, "\tORG 0\n");
+
+ /* copy the interrupt vector table */
+ if (mainf && mainf->fbody) {
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; interrupt vector \n");
+ fprintf (asmFile, "%s", iComments2);
+ copyFile (asmFile, vFile);
+ }
+
+ /* copy global & static initialisations */
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; global & static initialisations\n");
+ fprintf (asmFile, "%s", iComments2);
+
+ /* Everywhere we generate a reference to the static_name area,
+ * (which is currently only here), we immediately follow it with a
+ * definition of the post_static_name area. This guarantees that
+ * the post_static_name area will immediately follow the static_name
+ * area.
+ */
+ fprintf (asmFile, ";\t.area %s\n", port->mem.static_name); /* MOF */
+ fprintf (asmFile, ";\t.area %s\n", port->mem.post_static_name);
+ fprintf (asmFile, ";\t.area %s\n", port->mem.static_name);
+
+ if (mainf && mainf->fbody) {
+ 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);