From f4b70960beb52d44891535a4ba3af44e6b093eeb Mon Sep 17 00:00:00 2001 From: johanknol Date: Thu, 13 Sep 2001 15:04:32 +0000 Subject: [PATCH] Improved version of the experimental new initializer It should also work now for local's Remember the environmental var TRY_THE_NEW_INITIALIZER git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1267 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCast.c | 4 ++-- src/mcs51/gen.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/SDCCast.c b/src/SDCCast.c index 807ada66..5607e136 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1052,7 +1052,7 @@ ast * initAggregates (symbol * sym, initList * ival, ast * wid) { // copy this symbol newSym=copySymbol (sym); - SPEC_OCLS(newSym->type->next)=code; + SPEC_OCLS(newSym->etype)=code; sprintf (newSym->name, "%s_init__", sym->name); sprintf (newSym->rname,"%s_init__", sym->rname); addSym (SymbolTab, newSym, newSym->name, 0, 0, 1); @@ -1203,8 +1203,8 @@ processBlockVars (ast * tree, int *stack, int action) if (action == ALLOCATE) { - autoInit = gatherAutoInit (tree->values.sym); *stack += allocVariables (tree->values.sym); + autoInit = gatherAutoInit (tree->values.sym); /* if there are auto inits then do them */ if (autoInit) diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 6863646a..a67e54a2 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -8489,13 +8489,26 @@ void gen51AggregateAssign(iCode *ic) { int toSize=getSize(OP_SYMBOL(left)->type); int count=toSize; + if (SPEC_OCLS(OP_SYMBOL(left)->etype)!=xdata || + SPEC_OCLS(OP_SYMBOL(right)->etype)!=code) { + // well, this code isn't used yet from anywhere else as for initialising + fprintf (stderr, "*** error: %s:%d can only assign aggregates from cseg to xseg for now\n", ic->filename, ic->lineno); + exit (457); + } + if (fromSize!=toSize) { - fprintf (stderr, "*** error aggregates have different size"); - if (fromSizefilename, ic->lineno); + exit (821); } // memcpy from cseg to xseg + // this could be greatly improved here for multiple instances + // e.g.: + // mov dptr,#fromName + // mov r0:r1,#toName + // mov r2:r3,#count + // lcall _native_memcpy_cseg_to_xseg emitcode (";", "initialize %s", OP_SYMBOL(IC_LEFT(ic))->name); emitcode ("mov", "dptr,#_memcpy_PARM_2"); emitcode ("mov", "a,#%s", fromName); @@ -8504,7 +8517,7 @@ void gen51AggregateAssign(iCode *ic) { emitcode ("mov", "a,#(%s>>8)", fromName); emitcode ("movx", "@dptr,a"); emitcode ("inc", "dptr"); - emitcode ("mov", "a,#%02x; from cseg", 2); + emitcode ("mov", "a,#%02x; only from cseg for now", 2); emitcode ("movx", "@dptr,a"); emitcode ("mov", "dptr,#_memcpy_PARM_3"); emitcode ("mov", "a,#(%d>>0); number of bytes", count); -- 2.47.2