summaryrefslogtreecommitdiff
path: root/src/stm8
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-24 06:19:28 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-24 06:19:28 +0200
commitd5577a84aadd0195a95b5b4d83e49b40af49425b (patch)
tree39ef608e0743b5e2fdc09fa9f3bc113272a5713c /src/stm8
parent8eeb5d5444b2f29aa56fb1f0f8f20955c160e99e (diff)
downloadsdcc-gas-d5577a84aadd0195a95b5b4d83e49b40af49425b.tar.gz
Got hi8/lo8 asm instructions working
GNU as does not support the #</#> notation asxxx uses to determine address LSB and MSB. Instead, two instructions have been created on GNU as and ld (see my stm8-binutils-gdb fork) for this purpose. On the other hand, I'm upset to see gen.c does not provide an assembler-agnostic implementation when SDCCasm.c already provides tools already meant for this. OTOH, support for the "-C" has been added for --gas.
Diffstat (limited to 'src/stm8')
-rw-r--r--src/stm8/gen.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/stm8/gen.c b/src/stm8/gen.c
index 5870700..7dd5101 100644
--- a/src/stm8/gen.c
+++ b/src/stm8/gen.c
@@ -20,6 +20,7 @@
#include "ralloc.h"
#include "gen.h"
+#include "dbuf.h"
/* Use the D macro for basic (unobtrusive) debugging messages */
#define D(x) do if (options.verboseAsm) { x; } while (0)
@@ -435,10 +436,31 @@ aopGet(const asmop *aop, int offset)
{
wassertl_bt (offset < (2 + (options.model == MODEL_LARGE)), "Immediate operand out of range");
if (offset == 0)
- SNPRINTF (buffer, sizeof(buffer), "#<(%s + %d)", aop->aopu.immd, aop->aopu.immd_off);
+ {
+ struct dbuf_s temp;
+
+ dbuf_init(&temp, sizeof buffer);
+ /* SNPRINTF (buffer, sizeof(buffer), "#<(%s + %d)", aop->aopu.immd, aop->aopu.immd_off); */
+ SNPRINTF(buffer, sizeof buffer, "%s + %d", aop->aopu.immd, aop->aopu.immd_off);
+ dbuf_tprintf(&temp, "!lsbimmeds", buffer);
+ SNPRINTF(buffer, sizeof buffer, "%s", dbuf_c_str(&temp));
+ dbuf_destroy(&temp);
+
+ return buffer;
+ }
else
- SNPRINTF (buffer, sizeof(buffer), "#((%s + %d) >> %d)", aop->aopu.immd, aop->aopu.immd_off, offset * 8);
- return (buffer);
+ {
+ struct dbuf_s temp;
+
+ dbuf_init(&temp, sizeof buffer);
+ /* SNPRINTF (buffer, sizeof(buffer), "#((%s + %d) >> %d)", aop->aopu.immd, aop->aopu.immd_off, offset * 8); */
+ SNPRINTF(buffer, sizeof buffer, "%s + %d", aop->aopu.immd, aop->aopu.immd_off);
+ dbuf_tprintf(&temp, "!msbimmeds", buffer);
+ SNPRINTF(buffer, sizeof buffer, "%s", dbuf_c_str(&temp));
+ dbuf_destroy(&temp);
+
+ return buffer;
+ }
}
if (aop->type == AOP_DIR)