From 717cf743781d6240414f10bc16b532bf54c9efd1 Mon Sep 17 00:00:00 2001 From: johanknol Date: Fri, 18 Apr 2003 17:51:11 +0000 Subject: [PATCH] fixed bug #635354 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2536 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/mcs51/gen.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 473746c7..529be381 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -230,17 +230,26 @@ getFreePtr (iCode * ic, asmop ** aopp, bool result) (*aopp)->type = AOP_R1; return mcs51_regWithIdx (R1_IDX); } - endOfWorld: - /* I said end of world but not quite end of world yet */ - /* if this is a result then we can push it on the stack */ - if (result) - { - (*aopp)->type = AOP_STK; - return NULL; + /* I said end of world, but not quite end of world yet */ + if (result) { + /* we can push it on the stack */ + (*aopp)->type = AOP_STK; + return NULL; + } else { + /* in the case that result AND left AND right needs a pointer reg + we can safely use the result's */ + if (bitVectBitValue (mcs51_rUmaskForOp(IC_RESULT(ic)), R0_IDX)) { + (*aopp)->type = AOP_R0; + return mcs51_regWithIdx (R0_IDX); } + if (bitVectBitValue (mcs51_rUmaskForOp(IC_RESULT(ic)), R1_IDX)) { + (*aopp)->type = AOP_R1; + return mcs51_regWithIdx (R1_IDX); + } + } - /* other wise this is true end of the world */ + /* now this is REALLY the end of the world */ werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "getFreePtr should never reach here"); exit (1); -- 2.30.2