From affc5e817550e87639314a8c251b2921724415db Mon Sep 17 00:00:00 2001 From: johanknol Date: Sun, 16 Dec 2001 12:55:53 +0000 Subject: [PATCH] added seperate segments for initialized data git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1676 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/avr/main.c | 3 +++ src/ds390/gen.c | 20 +++++++-------- src/ds390/main.c | 7 +++-- src/ds390/ralloc.c | 10 ++++++-- src/izt/i186.c | 3 +++ src/izt/tlcs900h.c | 3 +++ src/mcs51/gen.c | 64 ---------------------------------------------- src/mcs51/main.c | 35 +++++++++++++++++++++++-- src/pic/gen.c | 5 ++-- src/pic/main.c | 3 +++ src/z80/main.c | 6 +++++ 11 files changed, 76 insertions(+), 83 deletions(-) diff --git a/src/avr/main.c b/src/avr/main.c index ba5a470b..01095753 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -185,6 +185,8 @@ PORT avr_port = { "OSEG", "GSFINAL", "HOME", + NULL, // initialized xdata + NULL, // a code copy of xiseg NULL, NULL, 0, @@ -205,6 +207,7 @@ PORT avr_port = { _avr_keywords, _avr_genAssemblerPreamble, _avr_genIVT, + NULL, // _avr_genXINIT _avr_reset_regparm, _avr_regparm, NULL, diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 6a073a73..10508322 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -3666,7 +3666,7 @@ genPlus (iCode * ic) while (size--) { MOVA (aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE, TRUE)); - emitcode ("addc", "a,#00"); + emitcode ("addc", "a,#0"); aopPut (AOP (IC_RESULT (ic)), "a", offset++); } _endLazyDPSEvaluation (); @@ -5062,24 +5062,24 @@ genCmp (operand * left, operand * right, CLRC; while (size--) { - emitcode (";", "genCmp #1: %d/%d/%d", size, sign, offset); + //emitcode (";", "genCmp #1: %d/%d/%d", size, sign, offset); MOVA (aopGet (AOP (left), offset, FALSE, FALSE, TRUE)); - emitcode (";", "genCmp #2"); + //emitcode (";", "genCmp #2"); if (sign && (size == 0)) { - emitcode (";", "genCmp #3"); + //emitcode (";", "genCmp #3"); emitcode ("xrl", "a,#0x80"); if (AOP_TYPE (right) == AOP_LIT) { unsigned long lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit); - emitcode (";", "genCmp #3.1"); + //emitcode (";", "genCmp #3.1"); emitcode ("subb", "a,#!constbyte", 0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL)); } else { - emitcode (";", "genCmp #3.2"); + //emitcode (";", "genCmp #3.2"); if (AOP_NEEDSACC (right)) { emitcode ("push", "acc"); @@ -5098,11 +5098,11 @@ genCmp (operand * left, operand * right, { const char *s; - emitcode (";", "genCmp #4"); + //emitcode (";", "genCmp #4"); if (AOP_NEEDSACC (right)) { /* Yuck!! */ - emitcode (";", "genCmp #4.1"); + //emitcode (";", "genCmp #4.1"); emitcode ("xch", "a, b"); MOVA (aopGet (AOP (right), offset++, FALSE, FALSE, TRUE)); emitcode ("xch", "a, b"); @@ -5110,7 +5110,7 @@ genCmp (operand * left, operand * right, } else { - emitcode (";", "genCmp #4.2"); + //emitcode (";", "genCmp #4.2"); s = aopGet (AOP (right), offset++, FALSE, FALSE, FALSE); } @@ -7831,7 +7831,7 @@ genLeftShiftLiteral (operand * left, aopOp(left, ic, FALSE, FALSE); aopOp(result, ic, FALSE, (AOP_TYPE(left) == AOP_DPTR)); -#if 1 // debug spew +#if 0 // debug spew if (IS_SYMOP(left) && OP_SYMBOL(left)->aop) { emitcode(";", "left (%s) is %d", OP_SYMBOL(left)->rname, AOP_TYPE(left)); diff --git a/src/ds390/main.c b/src/ds390/main.c index 45f04e03..03e68184 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -291,10 +291,12 @@ PORT ds390_port = "XSEG (XDATA)", "BSEG (BIT)", "RSEG (DATA)", - "GSINIT (CODE)", + /* "GSINIT (CODE)", */ "CSEG (CODE)", "OSEG (OVR,DATA)", "GSFINAL (CODE)", - "HOME (CODE)", + "HOME (CODE)", + NULL, // xidata + NULL, // xinit NULL, NULL, 1 @@ -316,6 +318,7 @@ PORT ds390_port = _ds390_keywords, _ds390_genAssemblerPreamble, _ds390_genIVT, + NULL, // _ds390_genXINIT _ds390_reset_regparm, _ds390_regparm, NULL, diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index a3385230..922c68b0 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -36,7 +36,7 @@ /* since the pack the registers depending strictly on the MCU */ /*-----------------------------------------------------------------*/ -#define D(x) +#define D(x) x /* Global data */ static struct @@ -2116,7 +2116,13 @@ packRegsDPTRuse (operand * op) if (OP_SYMBOL(IC_RESULT(ic))->liveTo == OP_SYMBOL(IC_RESULT(ic))->liveFrom) continue ; etype = getSpec(type = operandType(IC_RESULT(ic))); - if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic))) continue ; +#if 0 + if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic))) + continue ; +#else + if (getSize(type)==0) + continue; +#endif return NULL ; } diff --git a/src/izt/i186.c b/src/izt/i186.c index c9e19639..8ee41fb2 100644 --- a/src/izt/i186.c +++ b/src/izt/i186.c @@ -175,6 +175,8 @@ PORT i186_port = { ".DATA", ".TEXT", ".TEXT", + NULL, // xidata + NULL, // xinit NULL, NULL, 1 @@ -196,6 +198,7 @@ PORT i186_port = { _i186_keywords, _i186_genAssemblerPreamble, _i186_genIVT , + NULL, // _i186_genXINIT _i186_reset_regparm, _i186_regparm, NULL, diff --git a/src/izt/tlcs900h.c b/src/izt/tlcs900h.c index 3be389c1..02b37b38 100644 --- a/src/izt/tlcs900h.c +++ b/src/izt/tlcs900h.c @@ -174,6 +174,8 @@ PORT tlcs900h_port = "OSEG (OVR,DATA)", "GSFINAL (CODE)", "HOME (CODE)", + NULL, // xidata + NULL, // xinit NULL, NULL, 1 @@ -195,6 +197,7 @@ PORT tlcs900h_port = _tlcs900h_keywords, _tlcs900h_genAssemblerPreamble, _tlcs900h_genIVT, + 0, // _tlcs900h_genXINIT _tlcs900h_reset_regparm, _tlcs900h_regparm, NULL, diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 9a81b0cf..fdcca632 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -8744,66 +8744,6 @@ 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; - - D(emitcode (";", "gen51AggregateAssign")); - - 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 */ /*-----------------------------------------------------------------*/ @@ -9043,10 +8983,6 @@ gen51Code (iCode * lic) addSet (&_G.sendSet, ic); break; - case ARRAYINIT: - gen51AggregateAssign(ic); - break; - default: ic = ic; } diff --git a/src/mcs51/main.c b/src/mcs51/main.c index bbe4921c..41a7e1ac 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -120,6 +120,34 @@ _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) return FALSE; } +/* Generate code to copy XINIT to XISEG */ +static void _mcs51_genXINIT (FILE * of) { + fprintf (of, "; _mcs51_genXINIT() start\n"); + fprintf (of, " mov a,#s_XINIT\n"); + fprintf (of, " add a,#l_XINIT\n"); + fprintf (of, " mov r1,a\n"); + fprintf (of, " mov a,#s_XINIT>>8\n"); + fprintf (of, " addc a,#l_XINIT>>8\n"); + fprintf (of, " mov r2,a\n"); + fprintf (of, " mov dptr,#s_XINIT\n"); + fprintf (of, " mov r0,#s_XISEG\n"); + fprintf (of, " mov p2,#(s_XISEG >> 8)\n"); + fprintf (of, "00001$: clr a\n"); + fprintf (of, " movc a,@a+dptr\n"); + fprintf (of, " movx @r0,a\n"); + fprintf (of, " inc dptr\n"); + fprintf (of, " inc r0\n"); + fprintf (of, " cjne r0,#0,00002$\n"); + fprintf (of, " inc p2\n"); + fprintf (of, "00002$: mov a,dpl\n"); + fprintf (of, " cjne a,ar1,00001$\n"); + fprintf (of, " mov a,dph\n"); + fprintf (of, " cjne a,ar2,00001$\n"); + fprintf (of, " mov p2,#0xFF\n"); + fprintf (of, "; _mcs51_genXINIT() end\n"); +} + + /* Do CSE estimation */ static bool cseCostEstimation (iCode *ic, iCode *pdic) { @@ -200,10 +228,12 @@ PORT mcs51_port = "XSEG (XDATA)", "BSEG (BIT)", "RSEG (DATA)", - "GSINIT (CODE)", + /* "GSINIT (CODE)", */ "CSEG (CODE)", "OSEG (OVR,DATA)", "GSFINAL (CODE)", - "HOME (CODE)", + "HOME (CODE)", + "XISEG (XDATA)", // initialized xdata + "XINIT (CODE)", // a code copy of xiseg NULL, NULL, 1 @@ -225,6 +255,7 @@ PORT mcs51_port = _mcs51_keywords, _mcs51_genAssemblerPreamble, _mcs51_genIVT, + _mcs51_genXINIT, _mcs51_reset_regparm, _mcs51_regparm, NULL, diff --git a/src/pic/gen.c b/src/pic/gen.c index f34f6277..3fffd135 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -3482,6 +3482,7 @@ static void genSkipCond(resolvedIfx *rifx,operand *op, int offset, int bit) rifx->generated = 1; } +#if 0 /*-----------------------------------------------------------------*/ /* genChkZeroes :- greater or less than comparison */ /* For each byte in a literal that is zero, inclusive or the */ @@ -3508,6 +3509,7 @@ static int genChkZeroes(operand *op, int lit, int size) return (flag==0); } +#endif /*-----------------------------------------------------------------*/ /* genCmp :- greater or less than comparison */ @@ -3550,7 +3552,6 @@ static void genCmp (operand *left,operand *right, } else { symbol *lbl = newiTempLabel(NULL); - int flag; int emitFinalCheck=1; symbol *truelbl = newiTempLabel(NULL); @@ -3616,7 +3617,6 @@ static void genCmp (operand *left,operand *right, /* special cases */ if(sign) { - unsigned int mlit = -lit; if(lit == 0) { genSkipCond(&rIfx,left,size,7); @@ -3865,7 +3865,6 @@ static void genCmp (operand *left,operand *right, if(sign) { - int mlit = -lit; int lp1 = lit+1; size--; diff --git a/src/pic/main.c b/src/pic/main.c index d0cd1a33..d88ae7e2 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -265,6 +265,8 @@ PORT pic_port = "OSEG (OVR,DATA)", "GSFINAL (CODE)", "HOME (CODE)", + NULL, // xidata + NULL, // xinit NULL, NULL, 1 @@ -286,6 +288,7 @@ PORT pic_port = _pic14_keywords, _pic14_genAssemblerPreamble, _pic14_genIVT, + NULL, // _pic14_genXINIT _pic14_reset_regparm, _pic14_regparm, NULL, diff --git a/src/z80/main.c b/src/z80/main.c index 0f9f5a81..9c961879 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -486,6 +486,8 @@ PORT z80_port = "OVERLAY", "GSFINAL", "HOME", + NULL, // xidata + NULL, // xinit NULL, NULL, 1 @@ -507,6 +509,7 @@ PORT z80_port = _keywords, 0, /* no assembler preamble */ 0, /* no local IVT generation code */ + 0, /* no genXINIT code */ _reset_regparm, _reg_parm, _process_pragma, @@ -570,6 +573,8 @@ PORT gbz80_port = "OVERLAY", "GSFINAL", "HOME", + NULL, // xidata + NULL, // xinit NULL, NULL, 1 @@ -591,6 +596,7 @@ PORT gbz80_port = _keywords, 0, /* no assembler preamble */ 0, /* no local IVT generation code */ + 0, /* no genXINIT code */ _reset_regparm, _reg_parm, _process_pragma, -- 2.39.5