summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-21 03:04:31 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-21 03:04:31 +0200
commit41e45c2e8d8083be3157f2d7e884adf454332358 (patch)
treeda1e5cb9d6495fd79ea0514d57baa4690b5bd6c7 /src
parent3fcc2d265f1521c2dcae0734de355962cc6cd7a0 (diff)
GNU as now assembles successfully
A new (untested) startup routine has been written for GNU as. Section names have been considered from stm8-binutils linker script.
Diffstat (limited to 'src')
-rw-r--r--src/SDCCglue.c18
-rw-r--r--src/stm8/main.c91
2 files changed, 70 insertions, 39 deletions
diff --git a/src/SDCCglue.c b/src/SDCCglue.c
index 77a56ce..e8ea6b9 100644
--- a/src/SDCCglue.c
+++ b/src/SDCCglue.c
@@ -154,7 +154,7 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag)
if (options.gasOutput && !map->syms)
return;
- if (addPublics)
+ if (addPublics && !options.gasOutput)
{
/* PENDING: special case here - should remove */
if (!strcmp (map->sname, CODE_NAME))
@@ -162,8 +162,7 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag)
else if (!strcmp (map->sname, DATA_NAME))
{
dbuf_tprintf (&map->oBuf, "\t!areadata\n", map->sname);
- if (options.data_seg && strcmp (DATA_NAME, options.data_seg) && !options.gasOutput)
- /* GNU as only needs .bss. */
+ if (options.data_seg && strcmp (DATA_NAME, options.data_seg))
dbuf_tprintf (&map->oBuf, "\t!area\n", options.data_seg);
}
else if (!strcmp (map->sname, HOME_NAME))
@@ -174,6 +173,15 @@ emitRegularMap (memmap *map, bool addPublics, bool arFlag)
if (map->regsp)
dbuf_tprintf (&map->oBuf, "\t!org\n", 0);
}
+ else if (options.gasOutput)
+ if (map == code)
+ dbuf_tprintf (&map->oBuf, "\t!area\n", ".text");
+ else if (map == data)
+ dbuf_tprintf (&map->oBuf, "\t!area\n", DATA_NAME);
+ else if (map == initialized)
+ dbuf_tprintf (&map->oBuf, "\t!area\n", INITIALIZED_NAME);
+ else if (map == initializer)
+ dbuf_tprintf (&map->oBuf, "\t!area\n", INITIALIZER_NAME);
for (sym = setFirstItem (map->syms); sym; sym = setNextItem (map->syms))
{
@@ -2497,7 +2505,7 @@ glue (void)
snprintf( section_name, sizeof section_name / sizeof *section_name,
".%s", start_stack);
/* Set alloc/write flags. */
- tfprintf(asmFile, "\t!area , \"aw\", @progbits\n", section_name);
+ tfprintf(asmFile, "\t!area , \"aw\"\n", section_name);
tfprintf(asmFile, "\t!local\n", start_stack);
tfprintf(asmFile, "\t!comm\n\n", start_stack, size, 1);
}
@@ -2686,7 +2694,7 @@ glue (void)
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "; code\n");
fprintf (asmFile, "%s", iComments2);
- tfprintf (asmFile, "\t!areacode\n", options.code_seg);
+ tfprintf (asmFile, "\t!areacode\n", CODE_NAME);
dbuf_write_and_destroy (&code->oBuf, asmFile);
if (port->genAssemblerEnd)
diff --git a/src/stm8/main.c b/src/stm8/main.c
index c183137..424d4cb 100644
--- a/src/stm8/main.c
+++ b/src/stm8/main.c
@@ -240,41 +240,64 @@ stm8_genExtraArea (FILE *of, bool hasMain)
static void
stm8_genInitStartup (FILE *of)
{
- const char *const startup = options.gasOutput ?
- "_start"
- : "__sdcc_gs_init_startup";
+ if (!options.gasOutput)
+ {
+ tfprintf (of, "!labeldef\n", "__sdcc_gs_init_startup");
- tfprintf (of, "!labeldef\n", startup);
+ if (options.stack_loc >= 0)
+ {
+ fprintf (of, "\tldw\tx, #0x%04x\n", options.stack_loc);
+ fprintf (of, "\tldw\tsp, x\n");
+ }
- if (options.stack_loc >= 0)
+ /* Init static & global variables */
+ tfprintf (of, "!labeldef\n", "__sdcc_init_data");
+ fprintf (of, "; stm8_genXINIT() start\n");
+
+ /* Zeroing memory (required by standard for static & global variables) */
+ fprintf (of, "\tldw x, #l_DATA\n");
+ fprintf (of, "\tjreq\t00002$\n");
+ fprintf (of, "00001$:\n");
+ fprintf (of, "\tclr (s_DATA - 1, x)\n");
+ fprintf (of, "\tdecw x\n");
+ fprintf (of, "\tjrne\t00001$\n");
+ fprintf (of, "00002$:\n");
+
+ /* Copy l_INITIALIZER bytes from s_INITIALIZER to s_INITIALIZED */
+ fprintf (of, "\tldw\tx, #l_INITIALIZER\n");
+ fprintf (of, "\tjreq\t00004$\n");
+ fprintf (of, "00003$:\n");
+ fprintf (of, "\tld\ta, (s_INITIALIZER - 1, x)\n");
+ fprintf (of, "\tld\t(s_INITIALIZED - 1, x), a\n");
+ fprintf (of, "\tdecw\tx\n");
+ fprintf (of, "\tjrne\t00003$\n");
+ fprintf (of, "00004$:\n");
+ fprintf (of, "; stm8_genXINIT() end\n");
+ }
+ else
{
- fprintf (of, "\tldw\tx, #0x%04x\n", options.stack_loc);
- fprintf (of, "\tldw\tsp, x\n");
+ fprintf(of,
+ ".global _start\n"
+ "_start:\n"
+ "\t; Zeroing .bss\n"
+ "\tldw x, __bss_start\n"
+ "\t$0:\n"
+ "\tclr (x)\n"
+ "\tincw x\n"
+ "\tcpw x, __bss_end\n"
+ "\tjrne $0\n"
+ "\t; Copying .data from ROM to RAM\n"
+ "\t; Calculate .data section size\n"
+ "\tldw x, __data_load_start\n"
+ "\tldw y, __data_start\n"
+ "\t$1:\n"
+ "\tld a, (x)\n"
+ "\tld (y), a\n"
+ "\tincw x\n"
+ "\tincw y\n"
+ "\tcpw y, _edata\n"
+ "\tjrne $1\n");
}
-
- /* Init static & global variables */
- tfprintf (of, "!labeldef\n", "__sdcc_init_data");
- fprintf (of, "; stm8_genXINIT() start\n");
-
- /* Zeroing memory (required by standard for static & global variables) */
- fprintf (of, "\tldw x, #l_DATA\n");
- fprintf (of, "\tjreq\t00002$\n");
- fprintf (of, "00001$:\n");
- fprintf (of, "\tclr (s_DATA - 1, x)\n");
- fprintf (of, "\tdecw x\n");
- fprintf (of, "\tjrne\t00001$\n");
- fprintf (of, "00002$:\n");
-
- /* Copy l_INITIALIZER bytes from s_INITIALIZER to s_INITIALIZED */
- fprintf (of, "\tldw\tx, #l_INITIALIZER\n");
- fprintf (of, "\tjreq\t00004$\n");
- fprintf (of, "00003$:\n");
- fprintf (of, "\tld\ta, (s_INITIALIZER - 1, x)\n");
- fprintf (of, "\tld\t(s_INITIALIZED - 1, x), a\n");
- fprintf (of, "\tdecw\tx\n");
- fprintf (of, "\tjrne\t00003$\n");
- fprintf (of, "00004$:\n");
- fprintf (of, "; stm8_genXINIT() end\n");
}
#define STM8_INTERRUPTS_COUNT 30
@@ -286,10 +309,10 @@ stm8_genIVT(struct dbuf_s * oBuf, symbol ** intTable, int intCount)
if (options.gasOutput)
{
- dbuf_tprintf(oBuf, "!area , \"ax\", @progbits\n", ".text.__interrupt");
+ dbuf_tprintf(oBuf, "!area\n", ".vectors");
}
-
- dbuf_tprintf(oBuf, "\tint s_GSINIT ; reset\n");
+ else
+ dbuf_tprintf(oBuf, "\tint s_GSINIT ; reset\n");
if(intCount > STM8_INTERRUPTS_COUNT)
{