summaryrefslogtreecommitdiff
path: root/src/stm8/gen.c
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/gen.c
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/gen.c')
-rw-r--r--src/stm8/gen.c19
1 files changed, 13 insertions, 6 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);
}