summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-19 03:44:47 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-19 03:44:47 +0200
commita2a263dd383d76e4ee0ed62f393376ef2ae49171 (patch)
tree810d32d0296bae25d725cb2793f7b55d7239936d /src
parent35f6532764c90dabeb131b165101a5f931fd68bb (diff)
Creating GAS port in SDCCasm
SDCCasm proved a much more elegant way to implement GAS support for SDCC. In fact, I was surprised to see there was already an attempt that had been commented out. stm8-as only complaints about those nasty "Smain ==." statements, but that should be easy to fix.
Diffstat (limited to 'src')
-rw-r--r--src/SDCCasm.c88
-rw-r--r--src/SDCCasm.h5
2 files changed, 48 insertions, 45 deletions
diff --git a/src/SDCCasm.c b/src/SDCCasm.c
index 73f9e65..27f7cd1 100644
--- a/src/SDCCasm.c
+++ b/src/SDCCasm.c
@@ -400,7 +400,7 @@ err_no_line:
return dbuf_detach_c_str (&line);
}
-static const ASM_MAPPING _asxxxx_mapping[] = {
+static const ASM_MAPPING _gas_mapping[] = {
{"labeldef", "%s::"},
{"slabeldef", "%s:"},
{"tlabeldef", "%05d$:"},
@@ -408,25 +408,25 @@ static const ASM_MAPPING _asxxxx_mapping[] = {
{"immed", "#"},
{"zero", "#0x00"},
{"one", "#0x01"},
- {"area", ".area %s"},
- {"areacode", ".area %s"},
- {"areadata", ".area %s"},
- {"areahome", ".area %s"},
+ {"area", ".section %s"},
+ {"areacode", ".section .text"},
+ {"areadata", ".section .bss"},
+ {"areahome", ".section %s"},
{"ascii", ".ascii \"%s\""},
- {"ds", ".ds %d"},
- {"db", ".db"},
- {"dbs", ".db %s"},
- {"dw", ".dw"},
- {"dws", ".dw %s"},
+ {"ds", ".comm %d"},
+ {"db", ".byte"},
+ {"dbs", ".byte %s"},
+ {"dw", ".word"},
+ {"dws", ".word %s"},
{"constbyte", "0x%02x"},
{"constword", "0x%04x"},
- {"immedword", "#0x%04x"},
- {"immedbyte", "#0x%02x"},
+ {"immedword", "0x%04x"},
+ {"immedbyte", "0x%02x"},
{"hashedstr", "#%s"},
{"lsbimmeds", "#<(%s)"},
{"msbimmeds", "#>(%s)"},
- {"module", ".module %s"},
- {"global", ".globl %s"},
+ {"module", ".file \"%s\""},
+ {"global", ".global %s"},
{"fileprelude", ""},
{"functionheader",
"; ---------------------------------\n"
@@ -434,7 +434,6 @@ static const ASM_MAPPING _asxxxx_mapping[] = {
"; ---------------------------------"},
{"functionlabeldef", "%s:"},
{"globalfunctionlabeldef", "%s::"},
- {"bankimmeds", "0 ; PENDING: bank support"},
{"los", "(%s & 0xFF)"},
{"his", "(%s >> 8)"},
{"hihis", "(%s >> 16)"},
@@ -449,10 +448,10 @@ static const ASM_MAPPING _asxxxx_mapping[] = {
{"hihihil", "(%05d$ >> 24)"},
{"equ", "="},
{"org", ".org 0x%04X"},
- {NULL, NULL}
+ {0}
};
-static const ASM_MAPPING _asxxxx_smallpdk_mapping[] = {
+static const ASM_MAPPING _asxxxx_mapping[] = {
{"labeldef", "%s::"},
{"slabeldef", "%s:"},
{"tlabeldef", "%05d$:"},
@@ -466,11 +465,11 @@ static const ASM_MAPPING _asxxxx_smallpdk_mapping[] = {
{"areahome", ".area %s"},
{"ascii", ".ascii \"%s\""},
{"ds", ".ds %d"},
- {"db", "ret"},
- {"dbs", "ret %s"},
+ {"db", ".db"},
+ {"dbs", ".db %s"},
{"dw", ".dw"},
{"dws", ".dw %s"},
- {"constbyte", "#0x%02x"},
+ {"constbyte", "0x%02x"},
{"constword", "0x%04x"},
{"immedword", "#0x%04x"},
{"immedbyte", "#0x%02x"},
@@ -504,9 +503,7 @@ static const ASM_MAPPING _asxxxx_smallpdk_mapping[] = {
{NULL, NULL}
};
-#if 0
-/* not used */
-static const ASM_MAPPING _gas_mapping[] = {
+static const ASM_MAPPING _asxxxx_smallpdk_mapping[] = {
{"labeldef", "%s::"},
{"slabeldef", "%s:"},
{"tlabeldef", "%05d$:"},
@@ -514,26 +511,25 @@ static const ASM_MAPPING _gas_mapping[] = {
{"immed", "#"},
{"zero", "#0x00"},
{"one", "#0x01"},
- {"area", ".section %s"},
- {"areacode", ".section %s"},
- {"areadata", ".section %s"},
- {"areahome", ".section %s"},
+ {"area", ".area %s"},
+ {"areacode", ".area %s"},
+ {"areadata", ".area %s"},
+ {"areahome", ".area %s"},
{"ascii", ".ascii \"%s\""},
{"ds", ".ds %d"},
- {"db", ".db"},
- {"dbs", ".db %s"},
+ {"db", "ret"},
+ {"dbs", "ret %s"},
{"dw", ".dw"},
{"dws", ".dw %s"},
- {"constbyte", "0x%02X"},
- {"constword", "0x%04X"},
- {"immedword", "#0x%04X"},
- {"immedbyte", "#0x%02X"},
+ {"constbyte", "#0x%02x"},
+ {"constword", "0x%04x"},
+ {"immedword", "#0x%04x"},
+ {"immedbyte", "#0x%02x"},
{"hashedstr", "#%s"},
- {"lsbimmeds", "#<%s"},
- {"msbimmeds", "#>%s"},
- {"module", ".file \"%s.c\""},
+ {"lsbimmeds", "#<(%s)"},
+ {"msbimmeds", "#>(%s)"},
+ {"module", ".module %s"},
{"global", ".globl %s"},
- {"extern", ".globl %s"},
{"fileprelude", ""},
{"functionheader",
"; ---------------------------------\n"
@@ -542,9 +538,22 @@ static const ASM_MAPPING _gas_mapping[] = {
{"functionlabeldef", "%s:"},
{"globalfunctionlabeldef", "%s::"},
{"bankimmeds", "0 ; PENDING: bank support"},
+ {"los", "(%s & 0xFF)"},
+ {"his", "(%s >> 8)"},
+ {"hihis", "(%s >> 16)"},
+ {"hihihis", "(%s >> 24)"},
+ {"lod", "(%d & 0xFF)"},
+ {"hid", "(%d >> 8)"},
+ {"hihid", "(%d >> 16)"},
+ {"hihihid", "(%d >> 24)"},
+ {"lol", "(%05d$ & 0xFF)"},
+ {"hil", "(%05d$ >> 8)"},
+ {"hihil", "(%05d$ >> 16)"},
+ {"hihihil", "(%05d$ >> 24)"},
+ {"equ", "="},
+ {"org", ".org 0x%04X"},
{NULL, NULL}
};
-#endif
static const ASM_MAPPING _a390_mapping[] = {
{"labeldef", "%s:"},
@@ -608,13 +617,10 @@ const ASM_MAPPINGS asm_asxxxx_smallpdk_mapping = {
_asxxxx_smallpdk_mapping
};
-#if 0
-/* not used */
const ASM_MAPPINGS asm_gas_mapping = {
NULL,
_gas_mapping
};
-#endif
const ASM_MAPPINGS asm_a390_mapping = {
NULL,
diff --git a/src/SDCCasm.h b/src/SDCCasm.h
index 4bad706..d1fcdcd 100644
--- a/src/SDCCasm.h
+++ b/src/SDCCasm.h
@@ -51,11 +51,8 @@ extern const ASM_MAPPINGS asm_asxxxx_mapping;
/* The default mapping for small (<16 bit word) Padauk architectures.
*/
extern const ASM_MAPPINGS asm_asxxxx_smallpdk_mapping;
-#if 0
-/* not used */
-extern const ASM_MAPPINGS asm_gas_mapping;
-#endif
extern const ASM_MAPPINGS asm_a390_mapping;
+extern const ASM_MAPPINGS asm_gas_mapping;
/** Last entry has szKey = NULL.
*/