summaryrefslogtreecommitdiff
path: root/src/stm8
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-23 03:57:38 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-23 03:57:38 +0200
commit9c47d08e98953623ceac02c8422863e593deb40e (patch)
tree69c881d20ac0bc878bdd91da8dc2e668374a3dbc /src/stm8
parent4df948b3c184864525e7fa7e26ab380a70d644cd (diff)
downloadsdcc-gas-9c47d08e98953623ceac02c8422863e593deb40e.tar.gz
Implemented -c support for --gas
STM8 code generator was generating some instructions in a "ld register, (#%d, register)" way, causing assembling errors on stm8-as. This is because stm8-as does not require the '#' character. A quick and dirty workaround has been implemented for this. Added new warning W_IGNORED_OPT_IN_ASM, which warns the user when both "--no-optsdcc-in-asm" and "--gas" are used (the first is ignored when the latter is active since GNU as does not accept the .optsdcc directive, as opposed to asxxx).
Diffstat (limited to 'src/stm8')
-rw-r--r--src/stm8/gen.c19
-rw-r--r--src/stm8/main.c13
2 files changed, 23 insertions, 9 deletions
diff --git a/src/stm8/gen.c b/src/stm8/gen.c
index 80fd74e..5870700 100644
--- a/src/stm8/gen.c
+++ b/src/stm8/gen.c
@@ -3561,7 +3561,7 @@ genReturn (const iCode *ic)
for(i = 0; i < size; i++)
if (aopInReg (left->aop, i, A_IDX))
{
- emit2 ("ld", "(#%d, x), a", size - 1 - i);
+ emit2 ("ld", options.gasOutput ? "(%d, x), a" : "(#%d, x), a", size - 1 - i);
cost (2, 1);
break;
}
@@ -3573,7 +3573,7 @@ genReturn (const iCode *ic)
genMove_o (ASMOP_Y, 0, left->aop, i, 2, TRUE, FALSE, TRUE);
if (size - 2 - i)
{
- emit2 ("ldw", "(#%d, x), y", size - 2 - i);
+ emit2 ("ldw", options.gasOutput ? "(%d, x), y" : "(#%d, x), y", size - 2 - i);
cost (2, 2);
}
else
@@ -3585,8 +3585,9 @@ genReturn (const iCode *ic)
}
else if (aopInReg (left->aop, i, XL_IDX) || aopInReg (left->aop, i, XH_IDX))
{
- emit2 ("ld", "a, (#%d, sp)", (int)(aopInReg (left->aop, i, XL_IDX)) + 1);
- emit2 ("ld", "(#%d, x), a", size - 1 - i);
+ emit2 ("ld", options.gasOutput ? "a, (%d, sp)" : "a, (#%d, sp)",
+ (int)(aopInReg (left->aop, i, XL_IDX)) + 1);
+ emit2 ("ld", options.gasOutput ? "(%d, x), a" : "(#%d, x), a", size - 1 - i);
cost (4, 2);
i++;
}
@@ -3595,7 +3596,7 @@ genReturn (const iCode *ic)
cheapMove (ASMOP_A, 0, left->aop, i, FALSE);
if (size - 1 - i)
{
- emit2 ("ld", "(#%d, x), a", size - 1 - i);
+ emit2 ("ld", options.gasOutput ? "(%d, x), a" : "(#%d, x), a", size - 1 - i);
cost (2, 1);
}
else
@@ -7651,7 +7652,13 @@ genJumpTab (const iCode *ic)
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab; jtab = setNextItem (IC_JTLABELS (ic)))
{
if (!regalloc_dry_run)
- emit2 (".dw", "#!tlabel", labelKey2num (jtab->key));
+ {
+ struct dbuf_s b;
+
+ dbuf_init(&b, 1024);
+ /* emit2 (".dw", "#!tlabel", labelKey2num (jtab->key)); */
+ emit2 ("", "!dw %d", labelKey2num (jtab->key));
+ }
cost (2, 0);
}
diff --git a/src/stm8/main.c b/src/stm8/main.c
index b935f96..5c48247 100644
--- a/src/stm8/main.c
+++ b/src/stm8/main.c
@@ -285,8 +285,7 @@ stm8_genInitStartup (FILE *of)
"\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"
+ "\t; Transfer .data from ROM to RAM\n"
"\tldw x, __data_load_start\n"
"\tldw y, __data_start\n"
"1$:\n"
@@ -427,6 +426,11 @@ static const char *stm8AsmCmd[] =
"sdasstm8", "$l", "$3", "\"$1.asm\"", NULL
};
+static const char *stm8AsmGNUCmd[] =
+{
+ "stm8-as", "\"$1.asm\"", "-o", "\"$1.o\"", NULL
+};
+
static const char *const _libs_stm8[] = { "stm8", NULL, };
PORT stm8_port =
@@ -448,7 +452,9 @@ PORT stm8_port =
"-plosgffwy", /* Options with debug */
"-plosgffw", /* Options without debug */
0,
- ".asm"
+ ".asm",
+ NULL,
+ stm8AsmGNUCmd /* GNU assembler command */
},
{ /* Linker */
_linkCmd,
@@ -458,6 +464,7 @@ PORT stm8_port =
1,
NULL, /* crt */
_libs_stm8, /* libs */
+ ".o" /* ELF output extension */
},
{ /* Peephole optimizer */
stm8_defaultRules,