X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fmcs51%2Fgen.c;h=d012cd52accaca34e4465c061345d737e3311adc;hb=9e5e5ab1e6e0b2f06ba85296b76715dbbbaefbe3;hp=78725f19686023b03b2396b8423ef8041c9ed76c;hpb=64a9da6534ae075124cfbddbe1d2222cb0b42cb2;p=fw%2Fsdcc diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 78725f19..d012cd52 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -28,6 +28,9 @@ Made everything static -------------------------------------------------------------------------*/ +#define D(x) +//#define D(x) x + #include #include #include @@ -38,15 +41,19 @@ #ifdef HAVE_SYS_ISA_DEFS_H #include #else +#ifdef HAVE_MACHINE_ENDIAN_H +#include +#else #ifdef HAVE_ENDIAN_H #include #else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) +#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) #warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" #warning "If you running sdcc on an INTEL 80x86 Platform you are okay" #endif #endif #endif +#endif #include "common.h" #include "SDCCpeeph.h" @@ -162,9 +169,9 @@ getFreePtr (iCode * ic, asmop ** aopp, bool result) /* first check if r0 & r1 are used by this instruction, in which case we are in trouble */ - if ((r0iu = bitVectBitValue (ic->rUsed, R0_IDX)) && - (r1iu = bitVectBitValue (ic->rUsed, R1_IDX))) - { + r0iu = bitVectBitValue (ic->rUsed, R0_IDX); + r1iu = bitVectBitValue (ic->rUsed, R1_IDX); + if (r0iu && r1iu) { goto endOfWorld; } @@ -236,7 +243,7 @@ endOfWorld: /* other wise this is true end of the world */ werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "getFreePtr should never reach here"); - exit (0); + exit (1); } /*-----------------------------------------------------------------*/ @@ -270,7 +277,12 @@ static asmop * aopForSym (iCode * ic, symbol * sym, bool result) { asmop *aop; - memmap *space = SPEC_OCLS (sym->etype); + memmap *space; + + wassertl (ic != NULL, "Got a null iCode"); + wassertl (sym != NULL, "Got a null symbol"); + + space = SPEC_OCLS (sym->etype); /* if already has one */ if (sym->aop) @@ -552,7 +564,6 @@ aopOp (operand * op, iCode * ic, bool result) sym = OP_SYMBOL (op); - /* if the type is a conditional */ if (sym->regType == REG_CND) { @@ -589,6 +600,7 @@ aopOp (operand * op, iCode * ic, bool result) if (sym->ruonly) { unsigned i; + aop = op->aop = sym->aop = newAsmop (AOP_STR); aop->size = getSize (sym->type); for (i = 0; i < fReturnSizeMCS51; i++) @@ -846,7 +858,7 @@ aopGet (asmop * aop, int offset, bool bit16, bool dname) werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "aopget got unsupported aop->type"); - exit (0); + exit (1); } /*-----------------------------------------------------------------*/ /* aopPut - puts a string for a aop */ @@ -860,7 +872,7 @@ aopPut (asmop * aop, char *s, int offset) { werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "aopPut got offset > aop->size"); - exit (0); + exit (1); } /* will assign value to value */ @@ -905,7 +917,7 @@ aopPut (asmop * aop, char *s, int offset) { werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "aopPut writting to code space"); - exit (0); + exit (1); } while (offset > aop->coff) @@ -1003,7 +1015,7 @@ aopPut (asmop * aop, char *s, int offset) } { symbol *lbl = newiTempLabel (NULL); - emitcode ("clr", "c; oops"); + emitcode ("clr", "c"); emitcode ("jz", "%05d$", lbl->key + 100); emitcode ("cpl", "c"); emitcode ("", "%05d$:", lbl->key + 100); @@ -1031,7 +1043,7 @@ aopPut (asmop * aop, char *s, int offset) default: werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "aopPut got unsupported aop->type"); - exit (0); + exit (1); } } @@ -1430,7 +1442,6 @@ saveRegisters (iCode * lic) int i; iCode *ic; bitVect *rsave; - sym_link *detype; /* look for call */ for (ic = lic; ic; ic = ic->next) @@ -1445,8 +1456,8 @@ saveRegisters (iCode * lic) /* if the registers have been saved already or don't need to be then do nothing */ - if (ic->regsSaved || (OP_SYMBOL (IC_LEFT (ic))->calleeSave) || - SPEC_NAKED(OP_SYM_ETYPE(IC_LEFT (ic)))) + if (ic->regsSaved || IFFUNC_CALLEESAVES(OP_SYMBOL(IC_LEFT(ic))->type) || + IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT (ic)))) return; /* find the registers in use at this time @@ -1482,10 +1493,8 @@ saveRegisters (iCode * lic) if (bitVectBitValue (rsave, i)) emitcode ("push", "%s", mcs51_regWithIdx (i)->dname); } - - detype = getSpec (operandType (IC_LEFT (ic))); - } + /*-----------------------------------------------------------------*/ /* unsaveRegisters - pop the pushed registers */ /*-----------------------------------------------------------------*/ @@ -1611,6 +1620,8 @@ genIpush (iCode * ic) int size, offset = 0; char *l; + D(emitcode (";", "genIpush")); + /* if this is not a parm push : ie. it is spill push and spill push is always done on the local stack */ if (!ic->parmPush) @@ -1835,10 +1846,11 @@ saveRBank (int bank, iCode * ic, bool pushPsw) static void genCall (iCode * ic) { - sym_link *detype; + sym_link *dtype; bool restoreBank = FALSE; bool swapBanks = FALSE; + D(emitcode(";", "genCall")); /* if send set is not empty the assign */ if (_G.sendSet) { @@ -1868,17 +1880,17 @@ genCall (iCode * ic) /* if we are calling a not _naked function that is not using the same register bank then we need to save the destination registers on the stack */ - detype = getSpec (operandType (IC_LEFT (ic))); - if (detype && !SPEC_NAKED(detype) && - (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) && - IS_ISR (currFunc->etype)) + dtype = operandType (IC_LEFT (ic)); + if (dtype && !IFFUNC_ISNAKED(dtype) && + (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype)) && + IFFUNC_ISISR (currFunc->type)) { if (!ic->bankSaved) { /* This is unexpected; the bank should have been saved in * genFunction. */ - saveRBank (SPEC_BANK (detype), ic, FALSE); + saveRBank (FUNC_REGBANK (dtype), ic, FALSE); restoreBank = TRUE; } swapBanks = TRUE; @@ -1891,7 +1903,7 @@ genCall (iCode * ic) if (swapBanks) { emitcode ("mov", "psw,#0x%02x", - ((SPEC_BANK(detype)) << 3) & 0xff); + ((FUNC_REGBANK(dtype)) << 3) & 0xff); } /* make the call */ @@ -1902,7 +1914,7 @@ genCall (iCode * ic) if (swapBanks) { emitcode ("mov", "psw,#0x%02x", - ((SPEC_BANK(currFunc->etype)) << 3) & 0xff); + ((FUNC_REGBANK(currFunc->type)) << 3) & 0xff); } /* if we need assign a result value */ @@ -1938,12 +1950,12 @@ genCall (iCode * ic) } /* if we hade saved some registers then unsave them */ - if (ic->regsSaved && !(OP_SYMBOL (IC_LEFT (ic))->calleeSave)) + if (ic->regsSaved && !IFFUNC_CALLEESAVES(dtype)) unsaveRegisters (ic); /* if register bank was saved then pop them */ if (restoreBank) - unsaveRBank (SPEC_BANK (detype), ic, FALSE); + unsaveRBank (FUNC_REGBANK (dtype), ic, FALSE); } /*-----------------------------------------------------------------*/ @@ -1952,7 +1964,7 @@ genCall (iCode * ic) static void genPcall (iCode * ic) { - sym_link *detype; + sym_link *dtype; symbol *rlbl = newiTempLabel (NULL); @@ -1963,11 +1975,11 @@ genPcall (iCode * ic) /* if we are calling a function that is not using the same register bank then we need to save the destination registers on the stack */ - detype = getSpec (operandType (IC_LEFT (ic))); - if (detype && - IS_ISR (currFunc->etype) && - (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype))) - saveRBank (SPEC_BANK (detype), ic, TRUE); + dtype = operandType (IC_LEFT (ic)); + if (dtype && + IFFUNC_ISISR (currFunc->type) && + (FUNC_REGBANK (currFunc->type) != FUNC_REGBANK (dtype))) + saveRBank (FUNC_REGBANK (dtype), ic, TRUE); /* push the return address on to the stack */ @@ -2047,16 +2059,15 @@ genPcall (iCode * ic) } /* if register bank was saved then unsave them */ - if (detype && - (SPEC_BANK (currFunc->etype) != - SPEC_BANK (detype))) - unsaveRBank (SPEC_BANK (detype), ic, TRUE); + if (dtype && + (FUNC_REGBANK (currFunc->type) != + FUNC_REGBANK (dtype))) + unsaveRBank (FUNC_REGBANK (dtype), ic, TRUE); /* if we hade saved some registers then unsave them */ if (ic->regsSaved) unsaveRegisters (ic); - } /*-----------------------------------------------------------------*/ @@ -2112,7 +2123,7 @@ static void genFunction (iCode * ic) { symbol *sym; - sym_link *fetype; + sym_link *ftype; bool switchedPSW = FALSE; _G.nRegsSaved = 0; @@ -2122,25 +2133,25 @@ genFunction (iCode * ic) emitcode (";", "-----------------------------------------"); emitcode ("", "%s:", sym->rname); - fetype = getSpec (operandType (IC_LEFT (ic))); + ftype = operandType (IC_LEFT (ic)); - if (SPEC_NAKED(fetype)) + if (IFFUNC_ISNAKED(ftype)) { emitcode(";", "naked function: no prologue."); return; } /* if critical function then turn interrupts off */ - if (SPEC_CRTCL (fetype)) + if (IFFUNC_ISCRITICAL (ftype)) emitcode ("clr", "ea"); /* here we need to generate the equates for the register bank if required */ - if (SPEC_BANK (fetype) != rbank) + if (FUNC_REGBANK (ftype) != rbank) { int i; - rbank = SPEC_BANK (fetype); + rbank = FUNC_REGBANK (ftype); for (i = 0; i < mcs51_nRegs; i++) { if (strcmp (regs8051[i].base, "0") == 0) @@ -2157,7 +2168,7 @@ genFunction (iCode * ic) /* if this is an interrupt service routine then save acc, b, dpl, dph */ - if (IS_ISR (sym->etype)) + if (IFFUNC_ISISR (sym->type)) { if (!inExcludeList ("acc")) @@ -2171,13 +2182,13 @@ genFunction (iCode * ic) /* if this isr has no bank i.e. is going to run with bank 0 , then we need to save more registers :-) */ - if (!SPEC_BANK (sym->etype)) + if (!FUNC_REGBANK (sym->type)) { /* if this function does not call any other function then we can be economical and save only those registers that are used */ - if (!sym->hasFcall) + if (!IFFUNC_HASFCALL(sym->type)) { int i; @@ -2214,7 +2225,7 @@ genFunction (iCode * ic) */ unsigned long banksToSave = 0; - if (sym->hasFcall) + if (IFFUNC_HASFCALL(sym->type)) { #define MAX_REGISTER_BANKS 4 @@ -2232,20 +2243,20 @@ genFunction (iCode * ic) if (i->op == CALL) { - sym_link *detype; + sym_link *dtype; - detype = getSpec(operandType (IC_LEFT(i))); - if (detype - && SPEC_BANK(detype) != SPEC_BANK(sym->etype)) + dtype = operandType (IC_LEFT(i)); + if (dtype + && FUNC_REGBANK(dtype) != FUNC_REGBANK(sym->type)) { /* Mark this bank for saving. */ - if (SPEC_BANK(detype) >= MAX_REGISTER_BANKS) + if (FUNC_REGBANK(dtype) >= MAX_REGISTER_BANKS) { - werror(E_NO_SUCH_BANK, SPEC_BANK(detype)); + werror(E_NO_SUCH_BANK, FUNC_REGBANK(dtype)); } else { - banksToSave |= (1 << SPEC_BANK(detype)); + banksToSave |= (1 << FUNC_REGBANK(dtype)); } /* And note that we don't need to do it in @@ -2277,7 +2288,7 @@ genFunction (iCode * ic) */ emitcode ("push", "psw"); emitcode ("mov", "psw,#0x%02x", - (SPEC_BANK (sym->etype) << 3) & 0x00ff); + (FUNC_REGBANK (sym->type) << 3) & 0x00ff); switchedPSW = TRUE; } @@ -2289,6 +2300,7 @@ genFunction (iCode * ic) } } } + // jwk: this needs a closer look SPEC_ISR_SAVED_BANKS(currFunc->etype) = banksToSave; } } @@ -2296,7 +2308,7 @@ genFunction (iCode * ic) { /* if callee-save to be used for this function then save the registers being used in this function */ - if (sym->calleeSave) + if (IFFUNC_CALLEESAVES(sym->type)) { int i; @@ -2318,14 +2330,14 @@ genFunction (iCode * ic) } /* set the register bank to the desired value */ - if ((SPEC_BANK (sym->etype) || IS_ISR (sym->etype)) + if ((FUNC_REGBANK (sym->type) || IFFUNC_ISISR (sym->type)) && !switchedPSW) { emitcode ("push", "psw"); - emitcode ("mov", "psw,#0x%02x", (SPEC_BANK (sym->etype) << 3) & 0x00ff); + emitcode ("mov", "psw,#0x%02x", (FUNC_REGBANK (sym->type) << 3) & 0x00ff); } - if (IS_RENT (sym->etype) || options.stackAuto) + if (IFFUNC_ISREENT (sym->type) || options.stackAuto) { if (options.useXstack) @@ -2382,13 +2394,13 @@ genEndFunction (iCode * ic) { symbol *sym = OP_SYMBOL (IC_LEFT (ic)); - if (SPEC_NAKED(sym->etype)) + if (IFFUNC_ISNAKED(sym->type)) { emitcode(";", "naked function: no epilogue."); return; } - if (IS_RENT (sym->etype) || options.stackAuto) + if (IFFUNC_ISREENT (sym->type) || options.stackAuto) { emitcode ("mov", "%s,_bp", spname); } @@ -2404,7 +2416,7 @@ genEndFunction (iCode * ic) } - if ((IS_RENT (sym->etype) || options.stackAuto)) + if ((IFFUNC_ISREENT (sym->type) || options.stackAuto)) { if (options.useXstack) { @@ -2420,9 +2432,9 @@ genEndFunction (iCode * ic) } /* restore the register bank */ - if (SPEC_BANK (sym->etype) || IS_ISR (sym->etype)) + if (FUNC_REGBANK (sym->type) || IFFUNC_ISISR (sym->type)) { - if (!SPEC_BANK (sym->etype) || !IS_ISR (sym->etype) + if (!FUNC_REGBANK (sym->type) || !IFFUNC_ISISR (sym->type) || !options.useXstack) { /* Special case of ISR using non-zero bank with useXstack @@ -2432,19 +2444,19 @@ genEndFunction (iCode * ic) } } - if (IS_ISR (sym->etype)) + if (IFFUNC_ISISR (sym->type)) { /* now we need to restore the registers */ /* if this isr has no bank i.e. is going to run with bank 0 , then we need to save more registers :-) */ - if (!SPEC_BANK (sym->etype)) + if (!FUNC_REGBANK (sym->type)) { /* if this function does not call any other function then we can be economical and save only those registers that are used */ - if (!sym->hasFcall) + if (!IFFUNC_HASFCALL(sym->type)) { int i; @@ -2476,6 +2488,7 @@ genEndFunction (iCode * ic) * Restore any register banks saved by genFunction * in reverse order. */ + // jwk: this needs a closer look unsigned savedBanks = SPEC_ISR_SAVED_BANKS(currFunc->etype); int ix; @@ -2505,7 +2518,7 @@ genEndFunction (iCode * ic) if (!inExcludeList ("acc")) emitcode ("pop", "acc"); - if (SPEC_CRTCL (sym->etype)) + if (IFFUNC_ISCRITICAL (sym->type)) emitcode ("setb", "ea"); /* if debug then send end of function */ @@ -2527,10 +2540,10 @@ genEndFunction (iCode * ic) } else { - if (SPEC_CRTCL (sym->etype)) + if (IFFUNC_ISCRITICAL (sym->type)) emitcode ("setb", "ea"); - if (sym->calleeSave) + if (IFFUNC_CALLEESAVES(sym->type)) { int i; @@ -3240,12 +3253,17 @@ genMinus (iCode * ic) else { /* first add without previous c */ - if (!offset) - emitcode ("add", "a,#0x%02x", - (unsigned int) (lit & 0x0FFL)); - else + if (!offset) { + if (!size && lit==-1) { + emitcode ("dec", "a"); + } else { + emitcode ("add", "a,#0x%02x", + (unsigned int) (lit & 0x0FFL)); + } + } else { emitcode ("addc", "a,#0x%02x", (unsigned int) ((lit >> (offset * 8)) & 0x0FFL)); + } } aopPut (AOP (IC_RESULT (ic)), "a", offset++); } @@ -4191,6 +4209,9 @@ hasInc (operand *op, iCode *ic) iCode *lic = ic->next; int isize ; + /* this could from a cast, e.g.: "(char xdata *) 0x7654;" */ + if (!IS_SYMOP(op)) return NULL; + if (IS_BITVAR(retype)||!IS_PTR(type)) return NULL; isize = getSize(type->next); while (lic) { @@ -4202,7 +4223,7 @@ hasInc (operand *op, iCode *ic) return lic; } /* if the operand used or deffed */ - if (bitVectBitValue(ic->uses,op->key) || (unsigned) ic->defKey == op->key) { + if (bitVectBitValue(OP_USES(op),lic->key) || (unsigned) lic->defKey == op->key) { return NULL; } lic = lic->next; @@ -5246,6 +5267,12 @@ genRRC (iCode * ic) /* move it to the result */ size = AOP_SIZE (result); offset = size - 1; + if (size == 1) { /* special case for 1 byte */ + l = aopGet (AOP (left), offset, FALSE, FALSE); + MOVA (l); + emitcode ("rr", "a"); + goto release; + } CLRC; while (size--) { @@ -5263,6 +5290,7 @@ genRRC (iCode * ic) MOVA (l); } emitcode ("mov", "acc.7,c"); + release: aopPut (AOP (result), "a", AOP_SIZE (result) - 1); freeAsmop (left, NULL, ic, TRUE); freeAsmop (result, NULL, ic, TRUE); @@ -5291,6 +5319,10 @@ genRLC (iCode * ic) { l = aopGet (AOP (left), offset, FALSE, FALSE); MOVA (l); + if (size == 0) { /* special case for 1 byte */ + emitcode("rl","a"); + goto release; + } emitcode ("add", "a,acc"); if (AOP_SIZE (result) > 1) aopPut (AOP (result), "a", offset++); @@ -5311,6 +5343,7 @@ genRLC (iCode * ic) MOVA (l); } emitcode ("mov", "acc.0,c"); + release: aopPut (AOP (result), "a", 0); freeAsmop (left, NULL, ic, TRUE); freeAsmop (result, NULL, ic, TRUE); @@ -6776,7 +6809,7 @@ genUnpackBits (operand * result, char *rname, int ptype) case CPOINTER: emitcode ("clr", "a"); - emitcode ("movc", "a,%s", "@a+dptr"); + emitcode ("movc", "a,@a+dptr"); break; case GPOINTER: @@ -6829,7 +6862,7 @@ genUnpackBits (operand * result, char *rname, int ptype) case CPOINTER: emitcode ("clr", "a"); emitcode ("inc", "dptr"); - emitcode ("movc", "a", "@a+dptr"); + emitcode ("movc", "a,@a+dptr"); break; case GPOINTER: @@ -6941,8 +6974,9 @@ genNearPointerGet (operand * left, } else rname = aopGet (AOP (left), 0, FALSE, FALSE); - - aopOp (result, ic, FALSE); + + //aopOp (result, ic, FALSE); + aopOp (result, ic, result?TRUE:FALSE); /* if bitfield then unpack the bits */ if (IS_BITVAR (retype)) @@ -7543,24 +7577,47 @@ genNearPointerSet (operand * right, genDataPointerSet (right, result, ic); return; } - + /* if the value is already in a pointer register then don't need anything more */ if (!AOP_INPREG (AOP (result))) { - /* otherwise get a free pointer register */ - aop = newAsmop (0); - preg = getFreePtr (ic, &aop, FALSE); - emitcode ("mov", "%s,%s", - preg->name, - aopGet (AOP (result), 0, FALSE, TRUE)); - rname = preg->name; + if ( + //AOP_TYPE (result) == AOP_STK + IS_AOP_PREG(result) + ) + { + // Aha, it is a pointer, just in disguise. + rname = aopGet (AOP (result), 0, FALSE, FALSE); + if (*rname != '@') + { + fprintf(stderr, "probable internal error: unexpected rname @ %s:%d\n", + __FILE__, __LINE__); + } + else + { + // Expected case. + rname++; // skip the '@'. + } + } + else + { + /* otherwise get a free pointer register */ + aop = newAsmop (0); + preg = getFreePtr (ic, &aop, FALSE); + emitcode ("mov", "%s,%s", + preg->name, + aopGet (AOP (result), 0, FALSE, TRUE)); + rname = preg->name; + } + } + else + { + rname = aopGet (AOP (result), 0, FALSE, FALSE); } - else - rname = aopGet (AOP (result), 0, FALSE, FALSE); aopOp (right, ic, FALSE); - + /* if bitfield then unpack the bits */ if (IS_BITVAR (retype) || IS_BITVAR (letype)) genPackBits ((IS_BITVAR (retype) ? retype : letype), right, rname, POINTER); @@ -8012,6 +8069,8 @@ genAssign (iCode * ic) int size, offset; unsigned long lit = 0L; + D(emitcode(";","genAssign")); + result = IC_RESULT (ic); right = IC_RIGHT (ic); @@ -8146,6 +8205,8 @@ genCast (iCode * ic) operand *right = IC_RIGHT (ic); int size, offset; + D(emitcode(";", "genCast")); + /* if they are equivalent then do nothing */ if (operandsEqu (IC_RESULT (ic), IC_RIGHT (ic))) return; @@ -8154,7 +8215,8 @@ genCast (iCode * ic) aopOp (result, ic, FALSE); /* if the result is a bit */ - if (AOP_TYPE (result) == AOP_CRY) + // if (AOP_TYPE (result) == AOP_CRY /* works only for true symbols */ + if (IS_BITVAR(OP_SYMBOL(result)->type)) { /* if the right size is a literal then we know what the value is */ @@ -8444,6 +8506,64 @@ genReceive (iCode * ic) freeAsmop (IC_RESULT (ic), NULL, ic, TRUE); } +/*-----------------------------------------------------------------*/ +/* gen51AggregateAssign - copy complete array's or structures */ +/*-----------------------------------------------------------------*/ +void gen51AggregateAssign(iCode *ic) { + operand *left=IC_LEFT(ic); + operand *right=IC_RIGHT(ic); + char *fromName=OP_SYMBOL(right)->rname; + char *toName=OP_SYMBOL(left)->rname; + int fromSize=getSize(OP_SYMBOL(right)->type); + 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: %s:%d aggregates have different size\n", + ic->filename, ic->lineno); + exit (821); + } + +#if 1 + // use the generic memcpy() for now + emitcode (";", "initialize %s", OP_SYMBOL(IC_LEFT(ic))->name); + emitcode ("mov", "dptr,#_memcpy_PARM_2"); + emitcode ("mov", "a,#%s", fromName); + emitcode ("movx", "@dptr,a"); + emitcode ("inc", "dptr"); + emitcode ("mov", "a,#(%s>>8)", fromName); + emitcode ("movx", "@dptr,a"); + emitcode ("inc", "dptr"); + 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); + emitcode ("movx", "@dptr,a"); + emitcode ("inc", "dptr"); + emitcode ("mov", "a,#(%d>>8)", count); + emitcode ("movx", "@dptr,a"); + emitcode ("mov", "dptr,#%s", toName); + emitcode ("mov", "b,#%02x; only to xseg for now", 1); + emitcode ("lcall", "_memcpy"); +#else + // more efficient, but will require the native_memcpy_cs2xs + emitcode ("mov", "r0,#%s", fromName); + emitcode ("mov", "r1,#(%s>>8)", fromName); + emitcode ("mov", "r2,#%s", toName); + emitcode ("mov", "r3,#(%s>>8)", toName); + emitcode ("mov", "r4,#%d", count); + emitcode ("mov", "r5,#(%d>>8)", count); + emitcode ("lcall", "_native_memcpy_cs2xs"); +#endif +} + /*-----------------------------------------------------------------*/ /* gen51Code - generate code for 8051 based controllers */ /*-----------------------------------------------------------------*/ @@ -8684,6 +8804,10 @@ gen51Code (iCode * lic) addSet (&_G.sendSet, ic); break; + case ARRAYINIT: + gen51AggregateAssign(ic); + break; + default: ic = ic; }