diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-24 06:19:28 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-24 06:19:28 +0200 |
| commit | d5577a84aadd0195a95b5b4d83e49b40af49425b (patch) | |
| tree | 39ef608e0743b5e2fdc09fa9f3bc113272a5713c /src | |
| parent | 8eeb5d5444b2f29aa56fb1f0f8f20955c160e99e (diff) | |
| download | sdcc-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')
| -rw-r--r-- | src/SDCCasm.c | 4 | ||||
| -rw-r--r-- | src/SDCCglue.c | 15 | ||||
| -rw-r--r-- | src/port.h | 4 | ||||
| -rw-r--r-- | src/stm8/gen.c | 28 |
4 files changed, 42 insertions, 9 deletions
diff --git a/src/SDCCasm.c b/src/SDCCasm.c index 05551bd..ef92103 100644 --- a/src/SDCCasm.c +++ b/src/SDCCasm.c @@ -424,8 +424,8 @@ static const ASM_MAPPING _gas_mapping[] = { {"immedword", "0x%04x"}, {"immedbyte", "0x%02x"}, {"hashedstr", "#%s"}, - {"lsbimmeds", "#<(%s)"}, - {"msbimmeds", "#>(%s)"}, + {"lsbimmeds", "lo8(%s)"}, + {"msbimmeds", "hi8(%s)"}, {"module", ".file \"%s\""}, {"global", ".global %s"}, {"fileprelude", ""}, diff --git a/src/SDCCglue.c b/src/SDCCglue.c index d584303..9255137 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -1499,8 +1499,8 @@ printIvalFuncPtr (sym_link * type, initList * ilist, struct dbuf_s *oBuf) { if (TARGET_PDK_LIKE) { - dbuf_printf (oBuf, "\tret #<%s\n", name); - dbuf_printf (oBuf, "\tret #>%s\n", name); + dbuf_tprintf (oBuf, "\tret !lsbimmeds\n", name); + dbuf_tprintf (oBuf, "\tret !msbimmeds\n", name); } else if (TARGET_IS_STM8 && FUNCPTRSIZE == 3) { @@ -1560,7 +1560,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, struct dbuf_s *oBu { if (TARGET_PDK_LIKE && !TARGET_IS_PDK16) { - dbuf_printf (oBuf, "\tret #<%s\n", val->name); + dbuf_tprintf (oBuf, "\t!lsbimmeds", val->name); dbuf_printf (oBuf, IN_CODESPACE (SPEC_OCLS (val->etype)) ? "\tret #>(%s + 0x8000)\n" : "\tret #0\n", val->name); } else if (port->use_dw_for_init) @@ -2130,7 +2130,14 @@ createInterruptVect (struct dbuf_s *vBuf) return; } - dbuf_tprintf (vBuf, "\t!areacode\n", HOME_NAME); + dbuf_tprintf (vBuf, "\t!areacode", HOME_NAME); + + if (options.gasOutput) + /* Read-executable flags must be defined so ld can + * place the interrupt vectors into a separate section.*/ + dbuf_tprintf (vBuf, ",\t\"ax\""); + + dbuf_printf(vBuf, "\n"); dbuf_printf (vBuf, "__interrupt_vect:\n"); @@ -139,6 +139,8 @@ typedef struct const char *file_ext; /** If non-null will be used to execute the assembler. */ void (*do_assemble) (set *); + /** Command to run the GNU assembler. */ + const char **binutils_cmd; } assembler; @@ -157,6 +159,8 @@ typedef struct const int needLinkerScript; const char *const *crt; const char *const *libs; + /** Extension for ELF object files generated using GNU binutils (.o) */ + const char *o_ext; } linker; 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) |
