From d8762240297476467dadf8d2b366e39c99338b95 Mon Sep 17 00:00:00 2001 From: kvigor Date: Thu, 14 Sep 2000 23:03:07 +0000 Subject: [PATCH] Fix Karl's FarPointer bug git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@357 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/ds390/gen.c | 58 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 59fb5f7d..f24f651f 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -6583,13 +6583,32 @@ static void genFarPointerGet (operand *left, if (AOP_TYPE(left) != AOP_STR) { /* if this is remateriazable */ if (AOP_TYPE(left) == AOP_IMMD) + { emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE)); - else { /* we need to get it byte by byte */ - emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE)); - emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE)); - if (options.model == MODEL_FLAT24) + } + else + { + /* we need to get it byte by byte */ + if (AOP_TYPE(left) != AOP_DPTR) + { + emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE)); + if (options.model == MODEL_FLAT24) + { + emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE)); + } + } + else { - emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE)); + /* We need to generate a load to DPTR indirect through DPTR. */ + D(emitcode(";", "genFarPointerGet -- indirection special case.");); + emitcode("push", "%s", aopGet(AOP(left),0,FALSE,TRUE)); + emitcode("push", "%s", aopGet(AOP(left),1,FALSE,TRUE)); + emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE)); + emitcode("pop", "acc"); + emitcode("mov", "dph,a"); + emitcode("pop", "acc"); + emitcode("mov", "dpl,a"); } } } @@ -7156,18 +7175,35 @@ static void genFarPointerSet (operand *right, /* if this is remateriazable */ if (AOP_TYPE(result) == AOP_IMMD) emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE)); - else { /* we need to get it byte by byte */ - emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE)); - emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE)); - if (options.model == MODEL_FLAT24) + else + { + /* we need to get it byte by byte */ + if (AOP_TYPE(result) != AOP_DPTR) + { + emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE)); + emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE)); + if (options.model == MODEL_FLAT24) + { + emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE)); + } + } + else { - emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE)); + /* We need to generate a load to DPTR indirect through DPTR. */ + D(emitcode(";", "genFarPointerSet -- indirection special case.");); + emitcode("push", "%s", aopGet(AOP(result),0,FALSE,TRUE)); + emitcode("push", "%s", aopGet(AOP(result),1,FALSE,TRUE)); + emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE)); + emitcode("pop", "acc"); + emitcode("mov", "dph,a"); + emitcode("pop", "acc"); + emitcode("mov", "dpl,a"); } } } /* so dptr know contains the address */ freeAsmop(result,NULL,ic,TRUE); - aopOp(right,ic,FALSE, FALSE); + aopOp(right,ic,FALSE, TRUE); /* if bit then unpack */ if (IS_BITVAR(retype)) -- 2.47.2