From: johanknol Date: Mon, 21 Jan 2002 15:19:08 +0000 (+0000) Subject: added asm mappings for xa51 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=8b92dd26778ce77e3ad9dbf7e868acd9faca00d4;p=fw%2Fsdcc added asm mappings for xa51 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1831 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 53f2d85e..3ef98705 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -1143,7 +1143,7 @@ emitMaps () emitStaticSeg (statsg, code->oFile); if (port->genXINIT) { - fprintf (code->oFile, "\t.area\t%s\n", xinit->sname); + tfprintf (code->oFile, "\t!area\n", xinit->sname); emitStaticSeg (xinit, code->oFile); } inInitMode--; diff --git a/src/asm.c b/src/asm.c index cd819e43..66e8d201 100644 --- a/src/asm.c +++ b/src/asm.c @@ -383,6 +383,58 @@ static const ASM_MAPPING _a390_mapping[] = {NULL, NULL} }; +static const ASM_MAPPING _xa_asm_mapping[] = +{ + {"labeldef", "%s:"}, + {"slabeldef", "%s:"}, + {"tlabeldef", "L%05d:"}, + {"tlabel", "L%05d"}, + {"immed", "#"}, + {"zero", "#0"}, + {"one", "#1"}, + {"area", ".area %s"}, + {"areacode", ".area %s"}, + {"areadata", ".area %s"}, + {"areahome", ".area %s"}, + {"ascii", ".db \"%s\""}, + {"ds", ".ds %d"}, + {"db", ".db"}, + {"dbs", ".db \"%s\""}, + {"dw", ".dw"}, + {"dws", ".dw %s"}, + {"constbyte", "0%02xh"}, + {"constword", "0%04xh"}, + {"immedword", "#0%04Xh"}, + {"immedbyte", "#0%02Xh"}, + {"hashedstr", "#%s"}, + {"lsbimmeds", "#<%s"}, + {"msbimmeds", "#>%s"}, + {"module", ".module %s"}, + {"global", ".globl %s"}, + {"fileprelude", ""}, + {"functionheader", + "; ---------------------------------\n" + "; Function %s\n" + "; ---------------------------------" + }, + {"functionlabeldef", "%s:"}, + {"bankimmeds", "0 ; PENDING: bank support"}, + {"los","(%s & 0FFh)"}, + {"his","((%s / 256) & 0FFh)"}, + {"hihis","((%s / 65536) & 0FFh)"}, + {"hihihis","((%s / 16777216) & 0FFh)"}, + {"lod","(%d & 0FFh)"}, + {"hid","((%d / 256) & 0FFh)"}, + {"hihid","((%d / 65536) & 0FFh)"}, + {"hihihid","((%d / 16777216) & 0FFh)"}, + {"lol","(L%05d & 0FFh)"}, + {"hil","((L%05d / 256) & 0FFh)"}, + {"hihil","((L%05d / 65536) & 0FFh)"}, + {"hihihil","((L%09d / 16777216) & 0FFh)"}, + {"equ"," equ"}, + {NULL, NULL} +}; + const ASM_MAPPINGS asm_asxxxx_mapping = { NULL, @@ -400,3 +452,9 @@ const ASM_MAPPINGS asm_a390_mapping = NULL, _a390_mapping }; + +const ASM_MAPPINGS asm_xa_asm_mapping = +{ + NULL, + _xa_asm_mapping +}; diff --git a/src/asm.h b/src/asm.h index 96baca6b..3ae8fc6a 100644 --- a/src/asm.h +++ b/src/asm.h @@ -27,6 +27,7 @@ struct _ASM_MAPPINGS extern const ASM_MAPPINGS asm_asxxxx_mapping; extern const ASM_MAPPINGS asm_gas_mapping; extern const ASM_MAPPINGS asm_a390_mapping; +extern const ASM_MAPPINGS asm_xa_asm_mapping; /** Last entry has szKey = NULL. */ diff --git a/src/xa51/gen.c b/src/xa51/gen.c index ef5c986c..8653e54a 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -972,7 +972,13 @@ static void genPointerGet (iCode * ic, iCode *pi) { } else { instr=MOVW; } - emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]); + // if result=onstack + if (AOP_TYPE(result)==AOP_STK) { + emitcode (instr, "r0,[%s]", AOP_NAME(left)[0]); + emitcode (instr, "%s,r0", AOP_NAME(result)[0]); + } else { + emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]); + } if (AOP_SIZE(result) > 2) { // result is generic pointer sym_link *optype=operandType(left); @@ -996,7 +1002,7 @@ static void genPointerGet (iCode * ic, iCode *pi) { emitcode ("mov", "%s,r0", AOP_NAME(result)[0]); } } else { - if (AOP_SIZE(result)==3) { + if (AOP_SIZE(result)==1) { emitcode ("mov.b", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]); } else { emitcode ("mov.w", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]); @@ -1229,18 +1235,33 @@ static void genAssign (iCode * ic) { } else { instr=MOVW; } - emitcode (instr, "%s,%s", - result->aop->name[0], right->aop->name[0]); + if (AOP_TYPE(right)==AOP_STK && AOP_TYPE(result)==AOP_STK) { + emitcode (instr, "%s,%s", size==1 ? "r0l":"r0", right->aop->name[0]); + emitcode (instr, "%s,%s", AOP_NAME(result)[0], size==1 ? "r0l":"r0"); + } else { + emitcode (instr, "%s,%s", + result->aop->name[0], right->aop->name[0]); + } if (AOP_SIZE(result) > 2) { + if (AOP_TYPE(right)==AOP_LIT) { + emitcode (instr, "%s,%s", result->aop->name[1], + *AOP_NAME(right)[1] ? AOP_NAME(right)[1] : "#0x00"); + return; + } if (size==3) { instr=MOVB; } else { instr=MOVW; } - emitcode (instr, "%s,%s", - result->aop->name[1], right->aop->name[1]); + if (AOP_TYPE(right)==AOP_STK && AOP_TYPE(result)==AOP_STK) { + emitcode (instr, "%s,%s", size==1 ? "r0l":"r0", right->aop->name[1]); + emitcode (instr, "%s,%s", AOP_NAME(result)[1], size==1 ? "r0l":"r0"); + } else { + emitcode (instr, "%s,%s", + result->aop->name[1], right->aop->name[1]); + } + return; } - } /*-----------------------------------------------------------------*/ diff --git a/src/xa51/main.c b/src/xa51/main.c index 429a2cda..f7bb02d4 100755 --- a/src/xa51/main.c +++ b/src/xa51/main.c @@ -57,7 +57,7 @@ static int regParmFlg = 0; /* determine if we can register a parameter */ static void _xa51_init (void) { - asm_addTree (&asm_asxxxx_mapping); + asm_addTree (&asm_xa_asm_mapping); } static void