From f1692dca6f48601fcf7408c0ef9d06396c8dc388 Mon Sep 17 00:00:00 2001 From: kvigor Date: Tue, 6 Nov 2001 05:45:47 +0000 Subject: [PATCH] Arithmetic accelerator fixes: literal multiply/divide loaded MB in wrong order; multiply generated bad code if result was in ACC git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1512 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/ds390/gen.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 7c443247..3697e8d7 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -4095,9 +4095,9 @@ static void genMultTwoByte (operand *left, operand *right, if (val < 0) { emitcode("setb","F0"); val = -val; - } - emitcode ("mov","mb,#0x%02x",(val >> 8) & 0xff); + } emitcode ("mov","mb,#0x%02x",val & 0xff); + emitcode ("mov","mb,#0x%02x",(val >> 8) & 0xff); } else { lbl = newiTempLabel(NULL); emitcode ("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE,TRUE)); @@ -4169,7 +4169,19 @@ static void genMultTwoByte (operand *left, operand *right, emitcode("cpl","a"); emitcode("add","a,#1"); emitcode("","%05d$:", lbl->key+100); - aopPut(AOP(result),"a",0); + if (AOP_TYPE(result) == AOP_ACC) + { + D(emitcode(";", "ACC special case.");); + /* We know result is the only live aop, and + * it's obviously not a DPTR2, so AP is available. + */ + emitcode("mov", "%s,acc", DP2_RESULT_REG); + } + else + { + aopPut(AOP(result),"a",0); + } + emitcode("pop","acc"); lbl = newiTempLabel(NULL); emitcode("jnb","F0,%05d$",lbl->key+100); @@ -4195,6 +4207,11 @@ static void genMultTwoByte (operand *left, operand *right, emitcode("","%05d$:", lbl->key+100); aopPut(AOP(result),"a",3); } + if (AOP_TYPE(result) == AOP_ACC) + { + /* We stashed the result away above. */ + emitcode("mov", "acc,%s", DP2_RESULT_REG); + } } freeAsmop (result, NULL, ic, TRUE); @@ -4415,8 +4432,8 @@ static void genDivTwoByte (operand *left, operand *right, emitcode ("","%05d$:",lbl->key+100); val = -val; } + emitcode ("mov","mb,#0x%02x",val & 0xff); emitcode ("mov","mb,#0x%02x",(val >> 8) & 0xff); - emitcode ("mov","mb,#0x%02x",val & 0xff); } else { lbl = newiTempLabel(NULL); emitcode ("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE,TRUE)); -- 2.47.2