From: johanknol Date: Mon, 5 Mar 2001 16:19:13 +0000 (+0000) Subject: Cleaned up ds390 leftovers in the mcs51 port. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=1e268ec9106bf4b907eff98c705e11689c9dcb64;p=fw%2Fsdcc Cleaned up ds390 leftovers in the mcs51 port. Added target id's in port.h Fixed configure and makefile to build only enabled ports, and do a proper clean Renamed -mpic14 to -mpic git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@668 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 1d3ad655..b172d312 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -75,8 +75,7 @@ models: modelDS390: test -d ds390 || mkdir ds390 rm -f ds390/*.lib - $(MAKE) CFLAGS="$(CFLAGS) -mds390 --model-flat24 \ - --stack-10bit" objects + $(MAKE) CFLAGS="$(CFLAGS) -mds390" objects cd ds390; $(MAKE) cp *.lib ds390 mv *.rel *.asm *.cdb ds390 diff --git a/device/lib/ds390/Makefile b/device/lib/ds390/Makefile index 5770d98b..c30c9889 100755 --- a/device/lib/ds390/Makefile +++ b/device/lib/ds390/Makefile @@ -7,10 +7,7 @@ OBJECTS = tinibios.rel memcpyx.rel lcd390.rel i2c390.rel rtc390.rel SOURCES = $(patsubst %.rel,%.c,$(OBJECTS)) CPPFLAGS = -I../../include -CFLAGS = -mds390 \ - --model-flat24 \ - --stack-10bit \ - $(CPPFLAGS) $(VERBOSE) +CFLAGS = -mds390 $(CPPFLAGS) $(VERBOSE) all: $(OBJECTS) libds390.lib diff --git a/src/Makefile.in b/src/Makefile.in index 5e05f3be..a16e0455 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -8,7 +8,8 @@ include $(PRJDIR)/Makefile.common USE_ALT_LEX = 0 -PORTS = mcs51 z80 avr ds390 pic izt +PORTS = $(shell cat ../ports.build) +ALLPORTS = $(shell cat ../ports.all) PORT_LIBS = $(PORTS:%=%/port.a) LIBS = -lm @LIBS@ diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h index d1dc54c8..268a262e 100644 --- a/src/SDCCBBlock.h +++ b/src/SDCCBBlock.h @@ -96,7 +96,7 @@ int otherPathsPresent (eBBlock **, eBBlock *); void replaceLabel (eBBlock *, symbol *, symbol *); void dumpEbbsToFileExt (char *, eBBlock **, int); -#if defined(_MSC_VER) +//#if defined(_MSC_VER) /*-----------------------------------------------------------------*/ /* dumpLiveRanges - dump liverange information into a file */ @@ -104,6 +104,6 @@ void dumpEbbsToFileExt (char *, eBBlock **, int); void dumpLiveRanges (char *ext, hTab * liveRanges); -#endif // _MSC_VER +//#endif // _MSC_VER #endif diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 04d4452d..43c469a2 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -1214,7 +1214,7 @@ fixUpTypes (iCode * ic) { sym_link *t1 = operandType (IC_LEFT (ic)), *t2; - if (IS_DS390_PORT) + if (TARGET_IS_DS390) { /* hack-o-matic! */ return; diff --git a/src/SDCCglue.c b/src/SDCCglue.c index c2fea95f..3d88ce6d 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -463,7 +463,7 @@ pointerTypeToGPByte (const int p_type) void _printPointerType (FILE * oFile, const char *name) { - if (IS_DS390_PORT) + if (TARGET_IS_DS390) { fprintf (oFile, "\t.byte %s,(%s >> 8),(%s >> 16)", name, name, name); } diff --git a/src/SDCCicode.c b/src/SDCCicode.c index f47e69c5..3f7b868c 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -51,7 +51,7 @@ operand *geniCodeRValue (operand *, bool); operand *geniCodeDerefPtr (operand *); #define PRINTFUNC(x) void x (FILE *of, iCode *ic, char *s) -/* forward definition of print functions */ +/* forward definition of ic print functions */ PRINTFUNC (picGetValueAtAddr); PRINTFUNC (picSetValueAtAddr); PRINTFUNC (picAddrOf); @@ -1166,7 +1166,7 @@ operandFromSymbol (symbol * sym) /* under the following conditions create a register equivalent for a local symbol */ if (sym->level && sym->etype && SPEC_OCLS (sym->etype) && - (IN_FARSPACE (SPEC_OCLS (sym->etype)) && (!IS_DS390_PORT)) && + (IN_FARSPACE (SPEC_OCLS (sym->etype)) && (!TARGET_IS_DS390)) && options.stackAuto == 0) ok = 0; @@ -1519,7 +1519,7 @@ geniCodeRValue (operand * op, bool force) if (IS_SPEC (type) && IS_TRUE_SYMOP (op) && - (!IN_FARSPACE (SPEC_OCLS (etype)) || IS_DS390_PORT)) + (!IN_FARSPACE (SPEC_OCLS (etype)) || TARGET_IS_DS390)) { op = operandFromOperand (op); op->isaddr = 0; @@ -1678,19 +1678,11 @@ geniCodeMultiply (operand * left, operand * right, bool ptrSizeCalculation, } else { resType = usualBinaryConversions (&left, &right); - /* if (IS_DS390_PORT) { */ - /* jwk char*char=int - Now be can use the 16bit result of "mul a,b" instead of explicit - casts and support function calls as with --ansiint - */ - /* if ((IS_CHAR(letype) || IS_SHORT(letype)) && */ - /* (IS_CHAR(retype) || IS_SHORT(retype))) { */ if (resultIsInt) { SPEC_NOUN(getSpec(resType))=V_INT; SPEC_SHORT(getSpec(resType))=0; } } -/* } */ /* if the right is a literal & power of 2 */ /* then make it a left shift */ @@ -2794,7 +2786,7 @@ geniCodeReceive (value * args) if (IN_FARSPACE (SPEC_OCLS (sym->etype)) && options.stackAuto == 0 && - !IS_DS390_PORT) + !TARGET_IS_DS390) { } else diff --git a/src/SDCCmain.c b/src/SDCCmain.c index a40d0033..6490748a 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -158,7 +158,7 @@ static PORT *_ports[] = &ds390_port, #endif #if !OPT_DISABLE_PIC - &pic14_port, + &pic_port, #endif #if !OPT_DISABLE_I186 &i186_port, @@ -173,13 +173,13 @@ static PORT *_ports[] = /** remove me - TSD a hack to force sdcc to generate gpasm format .asm files. */ -extern void pic14glue (); +extern void picglue (); /** Sets the port to the one given by the command line option. @param The name minus the option (eg 'mcs51') @return 0 on success. */ -static int +static void _setPort (const char *name) { int i; @@ -188,7 +188,7 @@ _setPort (const char *name) if (!strcmp (_ports[i]->target, name)) { port = _ports[i]; - return 0; + return; } } /* Error - didnt find */ @@ -283,11 +283,11 @@ printVersionInfo () "SDCC : "); for (i = 0; i < NUM_PORTS; i++) fprintf (stderr, "%s%s", i == 0 ? "" : "/", _ports[i]->target); + fprintf (stderr, " %s" #ifdef SDCC_SUB_VERSION_STR "/" SDCC_SUB_VERSION_STR #endif - " ` " #ifdef __CYGWIN32__ " (CYGWIN32)\n" #else @@ -1034,10 +1034,7 @@ parseCmdLine (int argc, char **argv) case 'm': /* Used to select the port */ - if (_setPort (argv[i] + 2)) - { - werror (W_UNSUPP_OPTION, "-m", "Unrecognised processor"); - } + _setPort (argv[i] + 2); break; case 'a': @@ -1327,7 +1324,7 @@ linkEdit (char **envp) /* standard library path */ if (!options.nostdlib) { - if (IS_DS390_PORT) + if (TARGET_IS_DS390) { c = "ds390"; } @@ -1536,6 +1533,11 @@ main (int argc, char **argv, char **envp) /*printVersionInfo (); */ + if (NUM_PORTS==0) { + fprintf (stderr, "Build error: no ports are enabled.\n"); + exit (1); + } + _findPort (argc, argv); /* Initalise the port. */ if (port->init) @@ -1583,13 +1585,14 @@ main (int argc, char **argv, char **envp) if (!fatalError) { - if (IS_PIC14_PORT) + if (!TARGET_IS_PIC) { /* TSD PIC port hack - if the PIC port option is enabled and SDCC is used to generate PIC code, then we will generate .asm files in gpasm's format instead of SDCC's assembler's format */ - pic14glue (); + picglue (); + } else glue (); if (fatalError) diff --git a/src/SDCCset.c b/src/SDCCset.c index 24e936aa..007699ed 100644 --- a/src/SDCCset.c +++ b/src/SDCCset.c @@ -23,6 +23,7 @@ -------------------------------------------------------------------------*/ #include +#include #include "newalloc.h" #include #include "SDCCset.h" diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index aecca442..ae694d86 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1111,7 +1111,7 @@ checkSClass (symbol * sym) * control this allcoation, but the code was originally that way, and * changing it for non-390 ports breaks the compiler badly. */ - bool useXdata = IS_DS390_PORT ? options.model : options.useXstack; + bool useXdata = TARGET_IS_DS390 ? 1 : options.useXstack; SPEC_SCLS (sym->etype) = (useXdata ? S_XDATA : S_FIXED); } @@ -1421,7 +1421,7 @@ aggregateArgToPointer (value * val) DCL_TYPE (val->type) = PPOINTER; break; case S_FIXED: - if (IS_DS390_PORT) + if (TARGET_IS_DS390) { /* The AUTO and REGISTER classes should probably * also become generic pointers, but I haven't yet diff --git a/src/avr/main.c b/src/avr/main.c index c38e00a9..c2172bf1 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -147,6 +147,7 @@ static const char *_asmCmd[] = { /* Globals */ PORT avr_port = { + TARGET_ID_AVR, "avr", "ATMEL AVR", /* Target name */ { diff --git a/src/clean.mk b/src/clean.mk index b60ad6d7..165682d3 100644 --- a/src/clean.mk +++ b/src/clean.mk @@ -4,7 +4,7 @@ clean: rm -f *core *[%~] *.[oa] *.output rm -f .[a-z]*~ \#* rm -f $(PRJDIR)/bin/sdcc sdcc - for port in $(PORTS) ; do\ + for port in $(ALLPORTS) ; do\ $(MAKE) -C $$port -f clean.mk clean ;\ done diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 79c276c9..c1a45672 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -69,7 +69,7 @@ static char *spname; #define D(x) x -unsigned fReturnSize_390 = 5; /* shared with ralloc.c */ +unsigned fReturnSizeDS390 = 5; /* shared with ralloc.c */ static char *fReturn[] = {"dpl", "dph", "dpx", "b", "a"}; static char *accUse[] = @@ -769,7 +769,7 @@ aopOp (operand * op, iCode * ic, bool result, bool useDP2) aop = op->aop = sym->aop = newAsmop (AOP_STR); aop->size = getSize (sym->type); - for (i = 0; i < (int) fReturnSize_390; i++) + for (i = 0; i < (int) fReturnSizeDS390; i++) aop->aopu.aop_str[i] = fReturn[i]; return; } @@ -9194,11 +9194,11 @@ genReceive (iCode * ic) IS_TRUE_SYMOP (IC_RESULT (ic)))) { int size = getSize (operandType (IC_RESULT (ic))); - int offset = fReturnSize_390 - size; + int offset = fReturnSizeDS390 - size; while (size--) { - emitcode ("push", "%s", (strcmp (fReturn[fReturnSize_390 - offset - 1], "a") ? - fReturn[fReturnSize_390 - offset - 1] : "acc")); + emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeDS390 - offset - 1], "a") ? + fReturn[fReturnSizeDS390 - offset - 1] : "acc")); offset++; } aopOp (IC_RESULT (ic), ic, FALSE, FALSE); diff --git a/src/ds390/gen.h b/src/ds390/gen.h index c9589a0a..5ff118ec 100644 --- a/src/ds390/gen.h +++ b/src/ds390/gen.h @@ -75,6 +75,6 @@ asmop; void gen390Code (iCode *); -extern unsigned fReturnSize_390; +extern unsigned fReturnSizeDS390; #endif diff --git a/src/ds390/main.c b/src/ds390/main.c index cc688736..ee85833a 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -198,6 +198,7 @@ static const char *_asmCmd[] = /* Globals */ PORT ds390_port = { + TARGET_ID_DS390, "ds390", "DS80C390", /* Target name */ { diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index cd394735..f7ce298b 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -1885,7 +1885,7 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) /* only upto 2 bytes since we cannot predict the usage of b, & acc */ - if (getSize (operandType (op)) > (fReturnSize_390 - 2) && + if (getSize (operandType (op)) > (fReturnSizeDS390 - 2) && ic->op != RETURN && ic->op != SEND && !POINTER_SET (ic) && diff --git a/src/izt/i186.c b/src/izt/i186.c index 7b7829e5..d5769804 100644 --- a/src/izt/i186.c +++ b/src/izt/i186.c @@ -185,6 +185,7 @@ i186_assignRegisters (eBBlock ** ebbs, int count) /* Globals */ PORT i186_port = { + TARGET_ID_I186, "i186", "Intel 8086/80186", /* Target name */ { diff --git a/src/izt/tlcs900h.c b/src/izt/tlcs900h.c index e0151ea3..f8b2ac9f 100644 --- a/src/izt/tlcs900h.c +++ b/src/izt/tlcs900h.c @@ -131,6 +131,7 @@ tlcs900h_assignRegisters (eBBlock ** ebbs, int count) /* Globals */ PORT tlcs900h_port = { + TARGET_ID_TLCS900H, "tlcs900h", "Toshiba TLCS-900H", /* Target name */ { diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 4a1025f6..0b99a024 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -67,9 +67,7 @@ static char *spname; char *fReturn8051[] = {"dpl", "dph", "b", "a"}; -char *fReturn390[] = -{"dpl", "dph", "dpx", "b", "a"}; -unsigned fReturnSize = 4; /* shared with ralloc.c */ +unsigned fReturnSizeMCS51 = 4; /* shared with ralloc.c */ char **fReturn = fReturn8051; static char *accUse[] = {"a", "b"}; @@ -297,7 +295,7 @@ aopForSym (iCode * ic, symbol * sym, bool result) /* assign depending on the storage class */ /* if it is on the stack or indirectly addressable */ /* space we need to assign either r0 or r1 to it */ - if ((sym->onStack && !options.stack10bit) || sym->iaccess) + if (sym->onStack || sym->iaccess) { sym->aop = aop = newAsmop (0); aop->aopu.aop_ptr = getFreePtr (ic, &aop, result); @@ -335,35 +333,6 @@ aopForSym (iCode * ic, symbol * sym, bool result) return aop; } - if (sym->onStack && options.stack10bit) - { - /* It's on the 10 bit stack, which is located in - * far data space. - */ - - if (_G.accInUse) - emitcode ("push", "acc"); - - emitcode ("mov", "a,_bp"); - emitcode ("add", "a,#0x%02x", - ((sym->stack < 0) ? - ((char) (sym->stack - _G.nRegsSaved)) : - ((char) sym->stack)) & 0xff); - - genSetDPTR (1); - emitcode ("mov", "dpx1,#0x40"); - emitcode ("mov", "dph1,#0x00"); - emitcode ("mov", "dpl1, a"); - genSetDPTR (0); - - if (_G.accInUse) - emitcode ("pop", "acc"); - - sym->aop = aop = newAsmop (AOP_DPTR2); - aop->size = getSize (sym->type); - return aop; - } - /* if in bit space */ if (IN_BITSPACE (space)) { @@ -638,7 +607,7 @@ aopOp (operand * op, iCode * ic, bool result) int i; aop = op->aop = sym->aop = newAsmop (AOP_STR); aop->size = getSize (sym->type); - for (i = 0; i < fReturnSize; i++) + for (i = 0; i < fReturnSizeMCS51; i++) aop->aopu.aop_str[i] = fReturn[i]; return; } @@ -715,15 +684,6 @@ freeAsmop (operand * op, asmop * aaop, iCode * ic, bool pop) getFreePtr (ic, &aop, FALSE); - if (options.stack10bit) - { - /* I'm not sure what to do here yet... */ - /* #STUB */ - fprintf (stderr, - "*** Warning: probably generating bad code for " - "10 bit stack mode.\n"); - } - if (stk) { emitcode ("mov", "a,_bp"); @@ -2031,12 +1991,6 @@ genPcall (iCode * ic) emitcode ("mov", "a,#(%05d$ >> 8)", (rlbl->key + 100)); emitcode ("push", "acc"); - if (options.model == MODEL_FLAT24) - { - emitcode ("mov", "a,#(%05d$ >> 16)", (rlbl->key + 100)); - emitcode ("push", "acc"); - } - /* now push the calling address */ aopOp (IC_LEFT (ic), ic, FALSE); @@ -2222,20 +2176,6 @@ genFunction (iCode * ic) emitcode ("push", "dpl"); if (!inExcludeList ("dph")) emitcode ("push", "dph"); - if (options.model == MODEL_FLAT24 && !inExcludeList ("dpx")) - { - emitcode ("push", "dpx"); - /* Make sure we're using standard DPTR */ - emitcode ("push", "dps"); - emitcode ("mov", "dps, #0x00"); - if (options.stack10bit) - { - /* This ISR could conceivably use DPTR2. Better save it. */ - emitcode ("push", "dpl1"); - emitcode ("push", "dph1"); - emitcode ("push", "dpx1"); - } - } /* if this isr has no bank i.e. is going to run with bank 0 , then we need to save more registers :-) */ @@ -2434,17 +2374,6 @@ genEndFunction (iCode * ic) } } - if (options.model == MODEL_FLAT24 && !inExcludeList ("dpx")) - { - if (options.stack10bit) - { - emitcode ("pop", "dpx1"); - emitcode ("pop", "dph1"); - emitcode ("pop", "dpl1"); - } - emitcode ("pop", "dps"); - emitcode ("pop", "dpx"); - } if (!inExcludeList ("dph")) emitcode ("pop", "dph"); if (!inExcludeList ("dpl")) @@ -6966,10 +6895,6 @@ genFarPointerGet (operand * left, { /* 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) - { - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE)); - } } } /* so dptr know contains the address */ @@ -7019,10 +6944,6 @@ emitcodePointerGet (operand * left, { /* 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) - { - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE)); - } } } /* so dptr know contains the address */ @@ -7076,15 +6997,7 @@ genGenPointerGet (operand * left, { /* 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) - { - emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE)); - emitcode ("mov", "b,%s", aopGet (AOP (left), 3, FALSE, FALSE)); - } - else - { - emitcode ("mov", "b,%s", aopGet (AOP (left), 2, FALSE, FALSE)); - } + emitcode ("mov", "b,%s", aopGet (AOP (left), 2, FALSE, FALSE)); } } /* so dptr know contains the address */ @@ -7592,10 +7505,6 @@ genFarPointerSet (operand * right, { /* 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) - { - emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE)); - } } } /* so dptr know contains the address */ @@ -7650,15 +7559,7 @@ genGenPointerSet (operand * right, { /* 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) - { - emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE)); - emitcode ("mov", "b,%s", aopGet (AOP (result), 3, FALSE, FALSE)); - } - else - { - emitcode ("mov", "b,%s", aopGet (AOP (result), 2, FALSE, FALSE)); - } + emitcode ("mov", "b,%s", aopGet (AOP (result), 2, FALSE, FALSE)); } } /* so dptr know contains the address */ @@ -7806,25 +7707,10 @@ genAddrOf (iCode * ic) /* fill the result with zero */ size = AOP_SIZE (IC_RESULT (ic)) - 1; - - if (options.stack10bit && size < (FPTRSIZE - 1)) - { - fprintf (stderr, - "*** warning: pointer to stack var truncated.\n"); - } - offset = 1; while (size--) { - /* Yuck! */ - if (options.stack10bit && offset == 2) - { - aopPut (AOP (IC_RESULT (ic)), "#0x40", offset++); - } - else - { - aopPut (AOP (IC_RESULT (ic)), zero, offset++); - } + aopPut (AOP (IC_RESULT (ic)), zero, offset++); } goto release; @@ -8265,11 +8151,11 @@ genReceive (iCode * ic) { int size = getSize (operandType (IC_RESULT (ic))); - int offset = fReturnSize - size; + int offset = fReturnSizeMCS51 - size; while (size--) { - emitcode ("push", "%s", (strcmp (fReturn[fReturnSize - offset - 1], "a") ? - fReturn[fReturnSize - offset - 1] : "acc")); + emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeMCS51 - offset - 1], "a") ? + fReturn[fReturnSizeMCS51 - offset - 1] : "acc")); offset++; } aopOp (IC_RESULT (ic), ic, FALSE); diff --git a/src/mcs51/gen.h b/src/mcs51/gen.h index 567948f3..4c504579 100644 --- a/src/mcs51/gen.h +++ b/src/mcs51/gen.h @@ -40,20 +40,20 @@ enum typedef struct asmop { - short type; /* can have values - AOP_LIT - operand is a literal value - AOP_REG - is in registers - AOP_DIR - direct just a name - AOP_DPTR - dptr contains address of operand - AOP_DPTR2 - dptr2 contains address of operand (DS80C390 only). - AOP_R0/R1 - r0/r1 contains address of operand - AOP_STK - should be pushed on stack this - can happen only for the result - AOP_IMMD - immediate value for eg. remateriazable - AOP_CRY - carry contains the value of this - AOP_STR - array of strings - AOP_ACC - result is in the acc:b pair - */ + short type; + /* can have values + AOP_LIT - operand is a literal value + AOP_REG - is in registers + AOP_DIR - direct just a name + AOP_DPTR - dptr contains address of operand + AOP_R0/R1 - r0/r1 contains address of operand + AOP_STK - should be pushed on stack this + can happen only for the result + AOP_IMMD - immediate value for eg. remateriazable + AOP_CRY - carry contains the value of this + AOP_STR - array of strings + AOP_ACC - result is in the acc:b pair + */ short coff; /* current offset */ short size; /* total size */ unsigned code:1; /* is in Code space */ @@ -75,9 +75,8 @@ asmop; void gen51Code (iCode *); -extern char *fReturn8051[]; -extern char *fReturn390[]; -extern unsigned fReturnSize; -extern char **fReturn; +//extern char *fReturn8051[]; +extern unsigned fReturnSizeMCS51; +//extern char **fReturn; #endif diff --git a/src/mcs51/main.c b/src/mcs51/main.c index c9f6cd7f..2e85421e 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -83,30 +83,6 @@ _mcs51_parseOptions (int *pargc, char **argv, int *i) static void _mcs51_finaliseOptions (void) { - /* Hack-o-matic: if we are using the flat24 model, - * adjust pointer sizes. - */ - if (options.model == MODEL_FLAT24) - { - - fprintf (stderr, "*** WARNING: you should use the '-mds390' option " - "for DS80C390 support. This code generator is " - "badly out of date and probably broken.\n"); - - port->s.fptr_size = 3; - port->s.gptr_size = 4; - port->stack.isr_overhead++; /* Will save dpx on ISR entry. */ -#if 1 - port->stack.call_overhead++; /* This acounts for the extra byte - * of return addres on the stack. - * but is ugly. There must be a - * better way. - */ -#endif - fReturn = fReturn390; - fReturnSize = 5; - } - if (options.model == MODEL_LARGE) { port->mem.default_local_map = xdata; @@ -117,25 +93,6 @@ _mcs51_finaliseOptions (void) port->mem.default_local_map = data; port->mem.default_globl_map = data; } - - if (options.stack10bit) - { - if (options.model != MODEL_FLAT24) - { - fprintf (stderr, - "*** warning: 10 bit stack mode is only supported in flat24 model.\n"); - fprintf (stderr, "\t10 bit stack mode disabled.\n"); - options.stack10bit = 0; - } - else - { - /* Fixup the memory map for the stack; it is now in - * far space and requires a FPOINTER to access it. - */ - istack->fmap = 1; - istack->ptrType = FPOINTER; - } - } } static void @@ -154,45 +111,13 @@ _mcs51_getRegName (struct regs *reg) static void _mcs51_genAssemblerPreamble (FILE * of) { - if (options.model == MODEL_FLAT24) - { - fputs (".flat24 on\t\t; 24 bit flat addressing\n", of); - fputs ("dpx = 0x93\t\t; dpx register unknown to assembler\n", of); - fputs ("dps = 0x86\t\t; dps register unknown to assembler\n", of); - fputs ("dpl1 = 0x84\t\t; dpl1 register unknown to assembler\n", of); - fputs ("dph1 = 0x85\t\t; dph1 register unknown to assembler\n", of); - fputs ("dpx1 = 0x95\t\t; dpx1 register unknown to assembler\n", of); - } } /* Generate interrupt vector table. */ static int _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) { - int i; - - if (options.model != MODEL_FLAT24) - { - /* Let the default code handle it. */ - return FALSE; - } - - fprintf (of, "\tajmp\t__sdcc_gsinit_startup\n"); - - /* now for the other interrupts */ - for (i = 0; i < maxInterrupts; i++) - { - if (interrupts[i]) - { - fprintf (of, "\tljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname); - } - else - { - fprintf (of, "\treti\n\t.ds\t7\n"); - } - } - - return TRUE; + return FALSE; } /** $1 is always the basename. @@ -214,11 +139,12 @@ static const char *_asmCmd[] = /* Globals */ PORT mcs51_port = { + TARGET_ID_MCS51, "mcs51", "MCU 8051", /* Target name */ { TRUE, /* Emit glue around main */ - MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24, + MODEL_SMALL | MODEL_LARGE, MODEL_SMALL }, { diff --git a/src/mcs51/peeph.def b/src/mcs51/peeph.def index b089c32a..e6008fe9 100644 --- a/src/mcs51/peeph.def +++ b/src/mcs51/peeph.def @@ -539,20 +539,6 @@ replace { orl a,r%2 } -replace { - mov %1,a - mov dpl,%2 - mov dph,%3 - mov dpx,%4 - mov a,%1 -} by { - ; Peephole 136a removed redundant moves - mov %1,a - mov dpl,%2 - mov dph,%3 - mov dpx,%4 -} if 24bitMode - replace { mov %1,a mov dpl,%2 @@ -1041,15 +1027,6 @@ replace { clr a } -replace { - mov dpl,#0x00 - mov dph,#0x00 - mov dpx,#0x00 -} by { - ; Peephole 181a used 24 bit load of dptr - mov dptr,#0x0000 -} if 24bitMode - // saving 3 byte, 2 cycles, return(NULL) profits here replace { mov dpl,#0x00 @@ -1059,16 +1036,6 @@ replace { mov dptr,#0x0000 } -// saves 2 bytes, ?? cycles. -replace { - mov dpl,#%1 - mov dph,#(%1 >> 8) - mov dpx,#(%1 >> 16) -} by { - ; Peephole 182a used 24 bit load of dptr - mov dptr,#%1 -} if 24bitMode - // saving 3 byte, 2 cycles, return(float_constant) profits here replace { mov dpl,#%1 @@ -1608,13 +1575,6 @@ replace { inc %1 } -replace { - mov dptr,#((((%1 >> 16)) <<16) + (((%1 >> 8)) <<8) + %1) -} by { - ; Peephole 210a simplified expression - mov dptr,#%1 -} if 24bitMode - replace { mov dptr,#((((%1 >> 8)) <<8) + %1) } by { diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index a5a61a86..7c0c82b3 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -1889,7 +1889,7 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) /* only upto 2 bytes since we cannot predict the usage of b, & acc */ - if (getSize (operandType (op)) > (fReturnSize - 2) && + if (getSize (operandType (op)) > (fReturnSizeMCS51 - 2) && ic->op != RETURN && ic->op != SEND && !POINTER_SET (ic) && diff --git a/src/pic/gen.c b/src/pic/gen.c index 4cf02854..32a45cf0 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -73,7 +73,7 @@ static char *spname = "sp"; char *fReturnpic14[] = {"FSR","dph","b","a" }; //char *fReturn390[] = {"dpl","dph","dpx", "b","a" }; -static unsigned fReturnSize = 4; /* shared with ralloc.c */ +unsigned fReturnSizePic = 4; /* shared with ralloc.c */ static char **fReturn = fReturnpic14; static char *accUse[] = {"a","b"}; @@ -717,7 +717,7 @@ static void aopOp (operand *op, iCode *ic, bool result) int i; aop = op->aop = sym->aop = newAsmop(AOP_STR); aop->size = getSize(sym->type); - for ( i = 0 ; i < fReturnSize ; i++ ) + for ( i = 0 ; i < fReturnSizePic ; i++ ) aop->aopu.aop_str[i] = fReturn[i]; DEBUGemitcode(";","%d",__LINE__); return; @@ -8895,10 +8895,10 @@ static void genReceive (iCode *ic) IS_TRUE_SYMOP(IC_RESULT(ic))) ) { int size = getSize(operandType(IC_RESULT(ic))); - int offset = fReturnSize - size; + int offset = fReturnSizePic - size; while (size--) { - emitcode ("push","%s", (strcmp(fReturn[fReturnSize - offset - 1],"a") ? - fReturn[fReturnSize - offset - 1] : "acc")); + emitcode ("push","%s", (strcmp(fReturn[fReturnSizePic - offset - 1],"a") ? + fReturn[fReturnSizePic - offset - 1] : "acc")); offset++; } aopOp(IC_RESULT(ic),ic,FALSE); diff --git a/src/pic/gen.h b/src/pic/gen.h index a2ff10dd..686a818b 100644 --- a/src/pic/gen.h +++ b/src/pic/gen.h @@ -76,9 +76,9 @@ asmop; void genpic14Code (iCode *); -extern char *fReturnpic14[]; -extern char *fReturn390[]; -extern unsigned fReturnSize; -extern char **fReturn; +//extern char *fReturnpic14[]; +//extern char *fReturn390[]; +extern unsigned fReturnSizePic; +//extern char **fReturn; #endif diff --git a/src/pic/glue.c b/src/pic/glue.c index 77f6cc68..06616818 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -992,7 +992,7 @@ pic14emitOverlay (FILE * afile) /* glue - the final glue that hold the whole thing together */ /*-----------------------------------------------------------------*/ void -pic14glue () +picglue () { FILE *vFile; diff --git a/src/pic/main.c b/src/pic/main.c index e55b77ac..ebc5839b 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -83,6 +83,7 @@ _pic14_parseOptions (int *pargc, char **argv, int *i) static void _pic14_finaliseOptions (void) { +#if 0 /* Hack-o-matic: if we are using the flat24 model, * adjust pointer sizes. */ @@ -136,6 +137,7 @@ _pic14_finaliseOptions (void) istack->ptrType = FPOINTER; } } +#endif } static void @@ -207,8 +209,9 @@ static const char *_asmCmd[] = }; /* Globals */ -PORT pic14_port = +PORT pic_port = { + TARGET_ID_PIC, "pic14", "MCU pic", /* Target name */ { diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 244947d8..3a0ab79c 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -2334,7 +2334,7 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) /* only upto 2 bytes since we cannot predict the usage of b, & acc */ - if (getSize (operandType (op)) > (fReturnSize - 2) && + if (getSize (operandType (op)) > (fReturnSizePic - 2) && ic->op != RETURN && ic->op != SEND) return NULL; diff --git a/src/port.h b/src/port.h index e23528f8..db0eda65 100644 --- a/src/port.h +++ b/src/port.h @@ -5,9 +5,33 @@ #ifndef PORT_INCLUDE #define PORT_INCLUDE +#define TARGET_ID_MCS51 1 +#define TARGET_ID_GBZ80 2 +#define TARGET_ID_Z80 3 +#define TARGET_ID_AVR 4 +#define TARGET_ID_DS390 5 +#define TARGET_ID_PIC 6 +#define TARGET_ID_I186 7 +#define TARGET_ID_TLCS900H 8 +#define TARGET_ID_XA51 9 + +/* Macro to test the target we are compiling for. + Can only be used after SDCCmain has defined the port +*/ +#define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51) +#define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80) +#define TARGET_IS_Z80 (port->id==TARGET_ID_Z80) +#define TARGET_IS_AVR (port->id==TARGET_ID_AVR) +#define TARGET_IS_DS390 (port->id==TARGET_ID_DS390) +#define TARGET_IS_PIC (port->id==TARGET_ID_PIC) +#define TARGET_IS_I186 (port->id==TARGET_ID_I186) +#define TARGET_IS_TCLS900H (port->id==TARGET_ID_TCLS900H) + /* Processor specific names */ typedef struct { +/** Unique id for this target */ + const int id; /** Target name used for -m */ const char *target; @@ -16,7 +40,7 @@ typedef struct struct { - /** TRUE if all types of glue functions should be inseted into + /** TRUE if all types of glue functions should be inserted into the file that also defines main. We dont want this in cases like the z80 where the startup code is provided by a seperate module. @@ -134,7 +158,7 @@ typedef struct const char *fun_prefix; /** Called once the processor target has been selected. - First chance to initalise and set any port specific varibles. + First chance to initalise and set any port specific variables. 'port' is set before calling this. May be NULL. */ void (*init) (void); @@ -211,7 +235,7 @@ extern PORT avr_port; extern PORT ds390_port; #endif #if !OPT_DISABLE_PIC -extern PORT pic14_port; +extern PORT pic_port; #endif #if !OPT_DISABLE_I186 extern PORT i186_port; @@ -220,14 +244,4 @@ extern PORT i186_port; extern PORT tlcs900h_port; #endif -/* Test to see if we are current compiling in what? port. */ -#define IS_MCS51_PORT (port == &mcs51_port) -#define IS_GBZ80_PORT (port == &gbz80_port) -#define IS_Z80_PORT (port == &z80_port) -#define IS_AVR_PORT (port == &avr_port) -#define IS_DS390_PORT (port == &ds390_port) -#define IS_PIC14_PORT (port == &pic14_port) -#define IS_I186_PORT (port == &i186_port) -#define IS_TCLS900H_PORT (port == &tlcs900h_port) - #endif PORT_INCLUDE diff --git a/src/regression/Makefile b/src/regression/Makefile index 31b090bf..4442d5a3 100644 --- a/src/regression/Makefile +++ b/src/regression/Makefile @@ -72,7 +72,7 @@ all: test # The asm files are generated by sdcc .c.asm: - $(CC) -mpic14 -c $*.c + $(CC) -mpic -c $*.c # The .cod files are generated by gpasm # these get loaded by gpsim. diff --git a/src/z80/main.c b/src/z80/main.c index 45ebf1a6..78dfad94 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -317,6 +317,7 @@ static const char *_gbz80_asmCmd[] = /* Globals */ PORT z80_port = { + TARGET_ID_Z80, "z80", "Zilog Z80", /* Target name */ { @@ -391,6 +392,7 @@ PORT z80_port = /* Globals */ PORT gbz80_port = { + TARGET_ID_GBZ80, "gbz80", "Gameboy Z80-like", /* Target name */ {