XaviDCR92 / sdcc-gas

GNU assembler syntax support for SDCC
GNU General Public License v2.0
11 stars 1 forks source link

Wrong SBC asm in stm8 #7

Open sogrom opened 4 months ago

sogrom commented 4 months ago

Current version 3.9.0 generates wrong asm for stm8. getting errors:

 obj/main.asm:715: Error: stm8: call to md_operand
 obj/main.asm:715: Error: bad expression

Please see fix below:

diff --git a/src/stm8/gen.c b/src/stm8/gen.c
index 0d89633..1536392 100644
--- a/src/stm8/gen.c
+++ b/src/stm8/gen.c
@@ -2860,7 +2860,7 @@ genSub (const iCode *ic, asmop *result_aop, asmop *left_aop, asmop *right_aop)
                 emit3_o (started ? A_SBC : A_SUB, ASMOP_A, 0, right_aop, i);
               else
                 {
-                  emit2 (started ? "sbc" : "sub", "a, (#%d, sp)", right_offset);
+                  emit2 (started ? "sbc" : "sub", "a, (%d, sp)", right_offset);
                   cost (2, 1);
                 }

this was fixed in new version here:

https://github.com/swegener/sdcc/commit/02c36c6f6df2c28b027fbf2c43c20ef04779e0a5