Lots.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 22 Feb 2000 04:02:54 +0000 (04:02 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 22 Feb 2000 04:02:54 +0000 (04:02 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@115 4a8a32a2-be11-0410-ad9d-d568d2c75423

20 files changed:
as/z80/Makefile
as/z80/asmain.c
link/z80/Makefile
link/z80/lkmain.c
src/SDCCast.c
src/SDCCglobl.h
src/SDCCglue.c
src/SDCCicode.c
src/SDCCmain.c
src/SDCCopt.c
src/SDCCsymt.c
src/SDCCsymt.h
src/mcs51/main.c
src/port.h
src/z80/Makefile
src/z80/gbz80.c
src/z80/gen.c
src/z80/main.c
support/tests/dhrystone/Makefile
support/tests/dhrystone/dhry.c

index 25fce80053d5e3d1c9c9efdbc4e54e9b1dbab576..17520bcaf34b2f4893e1c991deeb287bc78a468f 100644 (file)
@@ -5,8 +5,9 @@ include $(TOPDIR)/Makefile.common
 SRC    = .
 OBJS   = asdata.o asexpr.o aslex.o aslist.o asmain.o asout.o \
          assubr.o assym.o z80adr.o z80ext.o z80mch.o z80pst.o
-BINS   = as$E
+BINS   = $(TOPDIR)/bin/as-gbz80$E
 
+CFLAGS += -DINDEXLIB -DMLH_MAP -DGAMEBOY -DUNIX -DSDK
 CFLAGS += -funsigned-char -ggdb
 LDFLAGS += -lm
 
index d407b3ebce283b380eb838bca71f4b6aa1245725..6e1aec7c7822316632c762cfdc27a52abdf13714 100644 (file)
  */
 
 VOID
-main(argc, argv)
-char *argv[];
+main(int argc, char **argv)
 {
        register char *p;
        register c, i;
index 3848c519b96f796e02af16f417bf4403cff2f00c..1ec1dbfdb2f1a017ce8102ad9eae5d3523c27a67 100644 (file)
@@ -5,8 +5,9 @@ include $(TOPDIR)/Makefile.common
 OBJS   = lkarea.o lkdata.o lkeval.o lkhead.o lkihx.o lklex.o \
          lklibr.o lklist.o lkmain.o lkrloc.o lks19.o lksym.o \
          lkgb.o lkgg.o
-BINS   = link$E
+BINS   = $(TOPDIR)/bin/link-gbz80$E 
 
+CFLAGS += -DINDEXLIB -DMLH_MAP -DGAMEBOY -DUNIX -DSDK -DSDK_VERSION_STRING="\"3.0.0\"" -DTARGET_STRING="\"gbz80\""
 CFLAGS += -funsigned-char -DUNIX
 
 all:   $(BINS)
index c2d8936e7cc50f2ebccbe56c6b488db270a7bf5f..1d59a2a7c7b18a937aa52c8c0468ad843d564616 100644 (file)
@@ -135,7 +135,7 @@ int binary = 0;
 #ifdef GAMEBOY
 char *default_basep[] = {
   "_CODE=0x0200",
-  "_BSS=0xC0A0",
+  "_DATA=0xC0A0",
   NULL
 };
 
index 772fadb78a5c385f9b3f8ef550db92f29b0abcd9..660db8da17986f196f47a6b3816d47cccb27afa4 100644 (file)
@@ -1517,7 +1517,7 @@ ast *decorateType (ast *tree)
                  TTYPE(tree) = TETYPE(tree) =
                    tree->opval.val->type = tree->opval.val->sym->type = 
                    tree->opval.val->etype = tree->opval.val->sym->etype = 
-                   copyLinkChain(intType);
+                   copyLinkChain(INTTYPE);
                }
                else {
                  
index 3f0c4bddba4ddcc8d9e4eb34aec5b123b6da06f3..bb71339cda72633df82bd205a4f71bf0fbb9a5de 100644 (file)
@@ -194,7 +194,9 @@ struct options {
     int debug     : 1  ; /* generate extra debug info */
     int stackOnData:1  ; /* stack after data segment  */
     int noregparms: 1  ; /* do not pass parameters in registers */
-    char *peep_file    ; /* additional rules for peep hole */    
+    int c1mode   : 1  ; /* Act like c1 - no pre-proc, asm or link */
+    char *peep_file    ; /* additional rules for peep hole */
+    char *out_name     ; /* Asm output name for c1 mode */
 
     char *calleeSaves[128]; /* list of functions using callee save */
     char *excludeRegs[32] ; /* registers excluded from saving */
index f80af473487d55c5fe0e524ba2b6b97130b48210..047074b9a3cd6ad99b7cde60357002ed6365fa45 100644 (file)
@@ -892,8 +892,13 @@ void glue ()
     if (options.debug)
        cdbStructBlock (0,cdbFile);
 
-    /* create the interrupt vector table */
-    createInterruptVect ((vFile = tmpfile ()));
+    vFile = tmpfile();
+    /* PENDING: this isnt the best place but it will do */
+    if (port->general.glue_up_main) {
+       /* create the interrupt vector table */
+       createInterruptVect (vFile);
+    }
+
     addSetHead(&tmpfileSet,vFile);
     
     /* emit code for the all the variables declared */
@@ -903,8 +908,15 @@ void glue ()
 
     /* now put it all together into the assembler file */
     /* create the assembler file name */
-    sprintf (buffer, srcFileName);
-    strcat (buffer, ".asm");
+    
+    if (!options.c1mode) {
+       sprintf (buffer, srcFileName);
+       strcat (buffer, ".asm");
+    }
+    else {
+       strcpy(buffer, options.out_name);
+    }
+
     if (!(asmFile = fopen (buffer, "w"))) {
        werror (E_FILE_OPEN_ERR, buffer);
        exit (1);
@@ -924,7 +936,6 @@ void glue ()
     
     /* print the global variables in this module */
     printPublics (asmFile);
-
     
     /* copy the sfr segment */
     fprintf (asmFile, "%s", iComments2);
index f42e063e1152dbfed8900fd214262de3f7001062..b633ce4d902f9358a83e0c209a1f3dac5c889851 100644 (file)
@@ -2674,7 +2674,7 @@ int geniCodeJumpTable (operand *cond, value *caseVals, ast *tree)
     /* if the min is not zero then we no make it zero */
     if (min) {
        cond = geniCodeSubtract(cond,operandFromLit(min));
-       setOperandType(cond,ucharType);
+       setOperandType(cond, UCHARTYPE);
     }
 
     /* now create the jumptable */
@@ -2903,7 +2903,7 @@ operand *ast2iCode (ast *tree)
     case GETHBIT:
        {
            operand *op = geniCodeUnary (geniCodeRValue(left,FALSE),tree->opval.op);
-           setOperandType(op,ucharType);
+           setOperandType(op, UCHARTYPE);
            return op;
        }
     case '>' :
index 2ad90c4ca9e5305f129d991b2c8092423f069c5d..6a9126d4f6e010a4dceee06e507aeb1509b6c847 100644 (file)
@@ -112,6 +112,7 @@ char    *preOutName;
 #define OPTION_VERSION     "-version"
 #define OPTION_STKAFTRDATA "-stack-after-data"
 #define OPTION_PREPROC_ONLY "-preprocessonly"
+#define OPTION_C1_MODE   "-c1mode"
 #define OPTION_HELP         "-help"
 #define OPTION_CALLEE_SAVES "-callee-saves"
 #define OPTION_NOREGPARMS   "-noregparms"
@@ -345,7 +346,7 @@ static void processFile (char *s)
     }
 
     /* otherwise depending on the file type */
-    if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0) {
+    if (strcmp(fext,".c") == 0 || strcmp(fext,".C") == 0 || options.c1mode) {
        /* source file name : not if we already have a 
           source file */
        if (srcFileName) {
@@ -402,6 +403,20 @@ static void processFile (char *s)
   
 }
 
+static void _processC1Arg(char *s)
+{
+    if (srcFileName) {
+       if (options.out_name) {
+           werror(W_TOO_MANY_SRC,s);
+           return;
+       }
+       options.out_name = strdup(s);
+    }
+    else {
+       processFile(s);
+    }
+}
+
 static void _addToList(const char **list, const char *str)
 {
     /* This is the bad way to do things :) */
@@ -536,6 +551,11 @@ int   parseCmdLine ( int argc, char **argv )
                 continue;
            }
 
+           if (strcmp(&argv[i][1],OPTION_C1_MODE) == 0) {
+               options.c1mode = 1;
+                continue;
+           }
+
            
            if (strcmp(&argv[i][1],OPTION_DUMP_ALL) == 0) {
                options.dump_rassgn = 
@@ -737,8 +757,10 @@ int   parseCmdLine ( int argc, char **argv )
        /* these are undocumented options */
        /* if preceded by '/' then turn off certain optmizations, used
           for debugging only these are also the legacy options from
-          version 1.xx will be removed gradually */
-       if ( *argv[i] == '/') {
+          version 1.xx will be removed gradually.
+          It may be an absolute filename.
+       */
+       if ( *argv[i] == '/' && strlen(argv[i]) < 3) {
            switch (argv[i][1]) {
                
            case 'p':
@@ -926,7 +948,10 @@ int   parseCmdLine ( int argc, char **argv )
 
        if (!port->parseOption(&argc, argv, &i)) {
            /* no option must be a filename */
-           processFile(argv[i]);
+           if (options.c1mode)
+               _processC1Arg(argv[i]);
+           else
+               processFile(argv[i]);
        }
     }  
 
@@ -1128,52 +1153,57 @@ static int preProcess (char **envp)
 
     preOutName = NULL;
 
-    /* if using external stack define the macro */
-    if ( options.useXstack )
-       _addToList(preArgv, "-DSDCC_USE_XSTACK");
-    
-    /* set the macro for stack autos   */
-    if ( options.stackAuto )
-       _addToList(preArgv, "-DSDCC_STACK_AUTO");
+    if (!options.c1mode) {
+       /* if using external stack define the macro */
+       if ( options.useXstack )
+           _addToList(preArgv, "-DSDCC_USE_XSTACK");
+       
+       /* set the macro for stack autos        */
+       if ( options.stackAuto )
+           _addToList(preArgv, "-DSDCC_STACK_AUTO");
     
-    /* set the macro for large model   */
-    switch(options.model)
-    {
-        case MODEL_LARGE:
-           _addToList(preArgv, "-DSDCC_MODEL_LARGE");
-           break;
-       case MODEL_SMALL:
-           _addToList(preArgv, "-DSDCC_MODEL_SMALL");
-           break;
-       case MODEL_FLAT24:
-           _addToList(preArgv, "-DSDCC_MODEL_FLAT24");
-           break;
-       default:
-           werror(W_UNKNOWN_MODEL, __FILE__, __LINE__);
-           break;
-    }      
+       /* set the macro for large model        */
+       switch(options.model)
+           {
+           case MODEL_LARGE:
+               _addToList(preArgv, "-DSDCC_MODEL_LARGE");
+               break;
+           case MODEL_SMALL:
+               _addToList(preArgv, "-DSDCC_MODEL_SMALL");
+               break;
+           case MODEL_FLAT24:
+               _addToList(preArgv, "-DSDCC_MODEL_FLAT24");
+               break;
+           default:
+               werror(W_UNKNOWN_MODEL, __FILE__, __LINE__);
+               break;
+           }       
            
     
-    /* add port (processor information to processor */
-    sprintf(procDef,"-DSDCC_%s",port->target);
-    _addToList(preArgv,procDef);
+       /* add port (processor information to processor */
+       sprintf(procDef,"-DSDCC_%s",port->target);
+       _addToList(preArgv,procDef);
 
-    if (!preProcOnly)
-       preOutName = strdup(tmpnam(NULL));
+       if (!preProcOnly)
+           preOutName = strdup(tmpnam(NULL));
 
-    _buildCmdLine(buffer, argv, _preCmd, fullSrcFileName, 
-                 preOutName, srcFileName, preArgv);
+       _buildCmdLine(buffer, argv, _preCmd, fullSrcFileName, 
+                     preOutName, srcFileName, preArgv);
 
-    if (my_system(argv[0], argv)) {
-       unlink (preOutName);
-       perror("Cannot exec Preprocessor");
-       exit(1);
-    }
+       if (my_system(argv[0], argv)) {
+           unlink (preOutName);
+           perror("Cannot exec Preprocessor");
+           exit(1);
+       }
 
-    if (preProcOnly)
-       exit(0);
+       if (preProcOnly)
+           exit(0);
+    }
+    else {
+       preOutName = fullSrcFileName;
+    }
 
-    yyin = fopen(preOutName,"r");
+    yyin = fopen(preOutName, "r");
     if (yyin == NULL) {
        perror("Preproc file not found\n");
        exit(1);
@@ -1218,7 +1248,7 @@ int main ( int argc, char **argv , char **envp)
     parseCmdLine(argc,argv);
 
     /* if no input then printUsage & exit */
-    if (!srcFileName && !nrelFiles) {
+    if ((!options.c1mode && !srcFileName && !nrelFiles) || (options.c1mode && !srcFileName && !options.out_name)) {
        printUsage();
        exit(0);
     }
@@ -1238,7 +1268,8 @@ int main ( int argc, char **argv , char **envp)
 
        if (!fatalError) {
            glue();
-           assemble(envp);
+           if (!options.c1mode)
+               assemble(envp);
        }
        
     }
@@ -1249,13 +1280,14 @@ int main ( int argc, char **argv , char **envp)
     if (!options.cc_only && 
        !fatalError      &&
        !noAssemble      &&
+       !options.c1mode  &&
        (srcFileName || nrelFiles))
        linkEdit (envp);
 
     if (yyin && yyin != stdin)
        fclose(yyin);
 
-    if (preOutName) {
+    if (preOutName && !options.c1mode) {
        unlink(preOutName);
        free(preOutName);
     }
index 25b44b9b83fa416011784a56d93b7e285ef5faca..642bff15857fdbd0baf9058c783b934ac7eaef84 100644 (file)
@@ -160,27 +160,22 @@ static void cnvToFloatCast (iCode *ic, eBBlock *ebp)
     symbol *func;
     link *type = operandType(IC_RIGHT(ic));
     int linenno = ic->lineno;
+    int bwd, su;
 
     ip = ic->next ;
     /* remove it from the iCode */
     remiCodeFromeBBlock (ebp,ic);
     /* depending on the type */
-    if (checkType(type,charType) == 1)
-       func = __char2fs ;
-    else
-       if (checkType(type,ucharType) == 1)
-           func = __uchar2fs;
-       else
-           if (checkType(type,intType) == 1)
-               func = __int2fs;
-           else
-               if (checkType(type,uintType) == 1)
-                   func = __uint2fs ;
-               else
-                   if (checkType(type,longType) == 1)
-                       func = __long2fs;
-                   else
-                       func = __ulong2fs ;
+    for (bwd = 0; bwd < 3; bwd++) {
+       for (su = 0; su < 2; su++) {
+           if (checkType(type, __multypes[bwd][su]) == 1) {
+               func = __conv[0][bwd][su];
+               goto found;
+           }
+       }
+    }
+    assert(0);
+ found:
 
     /* if float support routines NOT compiled as reentrant */
     if (! options.float_rent) {
@@ -224,28 +219,23 @@ static void cnvFromFloatCast (iCode *ic, eBBlock *ebp)
     symbol *func;
     link *type = operandType(IC_LEFT(ic));
     int lineno = ic->lineno ;
+    int bwd, su;
 
     ip = ic->next ;
     /* remove it from the iCode */
     remiCodeFromeBBlock (ebp,ic);
 
     /* depending on the type */
-    if (checkType(type,charType) == 1)
-       func = __fs2char ;
-    else
-       if (checkType(type,ucharType) == 1)
-           func = __fs2uchar;
-       else
-           if (checkType(type,intType) == 1)
-               func = __fs2int;
-           else
-               if (checkType(type,uintType) == 1)
-                   func = __fs2uint ;
-               else
-                   if (checkType(type,longType) == 1)
-                       func = __fs2long;
-                   else
-                       func = __fs2ulong ;
+    for (bwd = 0; bwd < 3; bwd++) {
+       for (su = 0; su < 2; su++) {
+           if (checkType(type, __multypes[bwd][su]) == 1) {
+               func = __conv[1][bwd][su];
+               goto found;
+           }
+       }
+    }
+    assert(0);
+ found:
 
     /* if float support routines NOT compiled as reentrant */
     if (! options.float_rent) {        
@@ -286,29 +276,32 @@ static void cnvFromFloatCast (iCode *ic, eBBlock *ebp)
 /*-----------------------------------------------------------------*/
 static void convilong (iCode *ic, eBBlock *ebp, link *type, int op)
 {    
-    symbol *func;
+    symbol *func = NULL;
     iCode *ip = ic->next;
     iCode *newic ;
     int lineno = ic->lineno;
-
+    int bwd;
+    int su;
     remiCodeFromeBBlock (ebp,ic);
 
     /* depending on the type */
-    if (checkType(type,intType) == 1)
-       func = (op == '*' ? __mulsint : 
-               (op == '%' ? __modsint :__divsint));
-    else
-       if (checkType(type,uintType) == 1)
-           func = (op == '*' ? __muluint : 
-                   (op == '%' ? __moduint : __divuint));
-       else
-           if (checkType(type,longType) == 1)
-               func = (op == '*' ? __mulslong : 
-                       (op == '%' ? __modslong : __divslong));
-           else
-               func = (op == '*'?  __mululong : 
-                       (op == '%' ? __modulong : __divulong));
-
+    for (bwd = 0; bwd < 3; bwd++) {
+       for (su = 0; su < 2; su++) {
+           if (checkType(type, __multypes[bwd][su]) == 1) {
+               if (op == '*')
+                   func = __muldiv[0][bwd][su];
+               else if (op == '/')
+                   func = __muldiv[1][bwd][su];
+               else if (op == '%')
+                   func = __muldiv[2][bwd][su];
+               else
+                   assert(0);
+               goto found;
+           }
+       }
+    }
+    assert(0);
+ found:
     /* if int & long support routines NOT compiled as reentrant */
     if (! options.intlong_rent) {
        /* first one */
@@ -401,7 +394,7 @@ static void convertToFcall (eBBlock **ebbs, int count)
            if (ic->op == '*' || ic->op == '/' || ic->op == '%' ) {
 
                link *type = operandType(IC_LEFT(ic));
-               if (IS_INTEGRAL(type) && getSize(type) > 1)
+               if (IS_INTEGRAL(type) && getSize(type) > port->muldiv.native_below)
                    convilong (ic,ebbs[i],type,ic->op);
            }
        }
index 2a956ab5c52301b41c3f58e2a9ba5038f2a5f38c..688e896685e4ea842a4cb18093000aa0ca616cd0 100644 (file)
@@ -1842,93 +1842,90 @@ symbol *__fslt  ;
 symbol *__fslteq;
 symbol *__fsgt  ;
 symbol *__fsgteq;
-symbol *__fs2uchar;
-symbol *__fs2uint ;
-symbol *__fs2ulong;
-symbol *__fs2char;
-symbol *__fs2int ;
-symbol *__fs2long;
-symbol *__long2fs;
-symbol *__ulong2fs;
-symbol *__int2fs;
-symbol *__uint2fs;
-symbol *__char2fs;
-symbol *__uchar2fs;
-symbol *__muluint;
-symbol *__mulsint;
-symbol *__divuint;
-symbol *__divsint;
-symbol *__mululong;
-symbol *__mulslong;
-symbol *__divulong;
-symbol *__divslong;
-symbol *__moduint;
-symbol *__modsint;
-symbol *__modulong;
-symbol *__modslong;
-
-link *charType ;
-link *intType  ;
+
+/* Dims: mul/div/mod, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
+symbol *__muldiv[3][3][2];
+/* Dims: BYTE/WORD/DWORD SIGNED/UNSIGNED */
+link *__multypes[3][2];
+/* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
+symbol *__conv[2][3][2];
+
 link *floatType;
-link *longType ;
-link *ucharType ;
-link *uintType  ;
-link *ulongType ;
 
 /*-----------------------------------------------------------------*/ 
 /* initCSupport - create functions for C support routines          */
 /*-----------------------------------------------------------------*/ 
 void initCSupport ()
 {
-    charType = newCharLink();
-    intType  = newIntLink();
+    const char *smuldivmod[] = {
+       "mul", "div", "mod"
+    };
+    const char *sbwd[] = {
+       "char", "int", "long"
+    };
+    const char *ssu[] = {
+       "s", "u"
+    };
+       
+    int bwd, su, muldivmod, tofrom;
+
     floatType= newFloatLink();
-    longType = newLongLink();
-    ucharType = copyLinkChain(charType);
-    SPEC_USIGN(ucharType) = 1;
-    ulongType = copyLinkChain(longType);
-    SPEC_USIGN(ulongType) = 1;
-    uintType = copyLinkChain(intType);
-    SPEC_USIGN(uintType) = 1;
 
+    for (bwd = 0; bwd < 3; bwd++) {
+       link *l;
+       switch (bwd) {
+       case 0:
+           l = newCharLink();
+           break;
+       case 1:
+           l = newIntLink();
+           break;
+       case 2:
+           l = newLongLink();
+           break;
+       default:
+           assert(0);
+       }
+       __multypes[bwd][0] = l;
+       __multypes[bwd][1] = copyLinkChain(l);
+       SPEC_USIGN(__multypes[bwd][1]) = 1;
+    }
 
     __fsadd = funcOfType ("__fsadd", floatType, floatType, 2, options.float_rent);
     __fssub = funcOfType ("__fssub", floatType, floatType, 2, options.float_rent);
     __fsmul = funcOfType ("__fsmul", floatType, floatType, 2, options.float_rent);
     __fsdiv = funcOfType ("__fsdiv", floatType, floatType, 2, options.float_rent);
-    __fseq  = funcOfType ("__fseq", charType, floatType, 2, options.float_rent);
-    __fsneq = funcOfType ("__fsneq", charType, floatType, 2, options.float_rent);
-    __fslt  = funcOfType ("__fslt", charType, floatType, 2, options.float_rent);
-    __fslteq= funcOfType ("__fslteq", charType, floatType, 2, options.float_rent);
-    __fsgt  = funcOfType ("__fsgt", charType, floatType, 2, options.float_rent);
-    __fsgteq= funcOfType ("__fsgteq", charType, floatType, 2, options.float_rent);
-    
-    __fs2uchar = funcOfType ("__fs2uchar",ucharType,floatType,1, options.float_rent);
-    __fs2uint  = funcOfType ("__fs2uint",uintType,floatType,1, options.float_rent);
-    __fs2ulong = funcOfType ("__fs2ulong",ulongType,floatType,1, options.float_rent);
-    __fs2char  = funcOfType ("__fs2char",charType,floatType,1, options.float_rent);
-    __fs2int   = funcOfType ("__fs2int",intType,floatType,1, options.float_rent);
-    __fs2long  = funcOfType ("__fs2long",longType,floatType,1, options.float_rent);
-
-    __long2fs  = funcOfType ("__long2fs",floatType,longType,1, options.float_rent);
-    __ulong2fs = funcOfType ("__ulong2fs",floatType,ulongType,1, options.float_rent);
-    __int2fs   = funcOfType ("__int2fs",floatType,intType,1, options.float_rent);
-    __uint2fs  = funcOfType ("__uint2fs",floatType,uintType,1, options.float_rent);
-    __char2fs  = funcOfType ("__char2fs",floatType,charType,1, options.float_rent);
-    __uchar2fs = funcOfType ("__uchar2fs",floatType,ucharType,1, options.float_rent);
-
-    __muluint  = funcOfType ("_muluint",uintType,uintType,2,options.intlong_rent);
-    __mulsint  = funcOfType ("_mulsint",intType,intType,2,options.intlong_rent);
-    __divuint  = funcOfType ("_divuint",uintType,uintType,2,options.intlong_rent);
-    __divsint  = funcOfType ("_divsint",intType,intType,2,options.intlong_rent);
-    __moduint  = funcOfType ("_moduint",uintType,uintType,2,options.intlong_rent);
-    __modsint  = funcOfType ("_modsint",intType,intType,2,options.intlong_rent);
-  
-    __mululong = funcOfType ("_mululong",ulongType,ulongType,2,options.intlong_rent);
-    __mulslong = funcOfType ("_mulslong",longType,longType,2,options.intlong_rent);
-    __divulong  = funcOfType ("_divulong",ulongType,ulongType,2,options.intlong_rent);
-    __divslong  = funcOfType ("_divslong",longType,longType,2,options.intlong_rent);
-    __modulong  = funcOfType ("_modulong",ulongType,ulongType,2,options.intlong_rent);
-    __modslong  = funcOfType ("_modslong",longType,longType,2,options.intlong_rent);
+    __fseq  = funcOfType ("__fseq", CHARTYPE, floatType, 2, options.float_rent);
+    __fsneq = funcOfType ("__fsneq", CHARTYPE, floatType, 2, options.float_rent);
+    __fslt  = funcOfType ("__fslt", CHARTYPE, floatType, 2, options.float_rent);
+    __fslteq= funcOfType ("__fslteq", CHARTYPE, floatType, 2, options.float_rent);
+    __fsgt  = funcOfType ("__fsgt", CHARTYPE, floatType, 2, options.float_rent);
+    __fsgteq= funcOfType ("__fsgteq", CHARTYPE, floatType, 2, options.float_rent);
+
+    for (tofrom = 0; tofrom < 2; tofrom++) {
+       for (bwd = 0; bwd < 3; bwd++) {
+           for (su = 0; su < 2; su++) {
+               if (tofrom) {
+                   sprintf(buffer, "__fs2%s%s", ssu[su], sbwd[bwd]);
+                   __conv[tofrom][bwd][su] = funcOfType(buffer, __multypes[bwd][su], floatType, 2, options.float_rent);
+               }
+               else {
+                   sprintf(buffer, "__%s%s2fs", ssu[su], sbwd[bwd]);
+                   __conv[tofrom][bwd][su] = funcOfType(buffer, floatType, __multypes[bwd][su], 2, options.float_rent);
+               }
+           }
+       }
+    }
+
+    for (muldivmod = 0; muldivmod < 3; muldivmod++) {
+       for (bwd = 0; bwd < 3; bwd++) {
+           for (su = 0; su < 2; su++) {
+               sprintf(buffer, "_%s%s%s", 
+                       smuldivmod[muldivmod],
+                       ssu[su],
+                       sbwd[bwd]);
+               __muldiv[muldivmod][bwd][su] = funcOfType(buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
+           }
+       }
+    }
 }
index 6f7ee2621bb805a47438a5d88d280a759bdd0794..73346afd20210799962a97759d0e776a767d3d05 100644 (file)
@@ -330,38 +330,19 @@ extern symbol *__fslt  ;
 extern symbol *__fslteq;
 extern symbol *__fsgt  ;
 extern symbol *__fsgteq;
-extern symbol *__fs2uchar;
-extern symbol *__fs2uint ;
-extern symbol *__fs2ulong;
-extern symbol *__fs2char;
-extern symbol *__fs2int ;
-extern symbol *__fs2long;
-extern symbol *__long2fs;
-extern symbol *__ulong2fs;
-extern symbol *__int2fs;
-extern symbol *__uint2fs;
-extern symbol *__char2fs;
-extern symbol *__uchar2fs;
-extern symbol *__muluint;
-extern symbol *__mulsint;
-extern symbol *__divuint;
-extern symbol *__divsint;
-extern symbol *__mululong;
-extern symbol *__mulslong;
-extern symbol *__divulong;
-extern symbol *__divslong;
-extern symbol *__moduint;
-extern symbol *__modsint;
-extern symbol *__modulong;
-extern symbol *__modslong;
 
-extern link *charType ;
-extern link *intType  ;
+/* Dims: mul/div/mod, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
+extern symbol *__muldiv[3][3][2];
+/* Dims: BYTE/WORD/DWORD SIGNED/UNSIGNED */
+extern link *__multypes[3][2];
+/* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
+extern symbol *__conv[2][3][2];
+
+#define CHARTYPE       __multypes[0][0]
+#define INTTYPE                __multypes[1][0]
+#define UCHARTYPE      __multypes[0][1]
+
 extern link *floatType;
-extern link *longType ;
-extern link *ucharType ;
-extern link *uintType  ;
-extern link *ulongType ;
 
 #include "SDCCval.h"
 
index e4732ad90d768544c4d0e92b44ae8db5ea40af95..62881b54370a4983e1ac5c7f4f14bf2a5b973f31 100644 (file)
@@ -142,6 +142,9 @@ static const char *_asmCmd[] = {
 PORT mcs51_port = {
     "mcs51",
     "MCU 8051",                        /* Target name */
+    {
+       TRUE,                   /* Emit glue around main */
+    },
     {  
        _asmCmd,
        "-plosgffc",            /* Options with debug */
index 76ebfbd62606a1254a60c9cf785e621f291fd44f..b8639fb1fe3298abc80df1c4917830f1aa4c3d47 100644 (file)
@@ -13,6 +13,15 @@ typedef struct {
     /** Target name string, used for --help */
     const char *target_name;
 
+    struct {
+       /** TRUE if all types of glue functions should be inseted 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.
+       */
+       bool glue_up_main;
+    } general;
+
     /* assembler related information */
     struct {
        /** Command to run and arguments (eg as-z80) */
@@ -80,7 +89,7 @@ typedef struct {
        /** One more than the smallest 
            mul/div operation the processor can do nativley 
            Eg if the processor has an 8 bit mul, nativebelow is 2 */
-       int nativebelow;
+       int native_below;
     } muldiv;
 
     /** Called once the processor target has been selected.
index f3b71b324ba98f6b8c57389587405f679c5d5614..e71232b6c114775a936ce385987c3708c869331e 100644 (file)
@@ -22,6 +22,6 @@ peeph-gbz80.rul: peeph-gbz80.def
        $(AWK) -f ../SDCCpeeph.awk peeph-gbz80.def > peeph-gbz80.rul
 
 main.o: main.c peeph.rul
-gbz80.o: gbz80.o peeph-gbz80.rul
+gbz80.o: gbz80.c peeph-gbz80.rul
 
 include clean.mk
index d0b2f88ab49b753d75a1a2c80758e9f54954b891..84946032bd2698ae84a4a8117a1513f6d90e0022 100644 (file)
@@ -73,6 +73,9 @@ static const char *_asmCmd[] = {
 PORT gbz80_port = {
     "gbz80",
     "Gameboy Z80-like",                /* Target name */
+    {
+       FALSE,
+    },
     {  
        _asmCmd,
        "-plosgff",             /* Options with debug */
index 029cbfad14b8eb8bcc91971fde49ebbfb61a2286..a46c959d975a03c6b3332235feb6aacfeaacefcc 100644 (file)
@@ -2343,7 +2343,7 @@ static void genOrOp (iCode *ic)
         toBoolean(left);
         emitcode(_shortJP, "nz," LABEL_STR,tlbl->key+100);
         toBoolean(right);
-        emitcode("", LABEL_STR,tlbl->key+100);
+        emitcode("", LABEL_STR ":",tlbl->key+100);
         outBitAcc(result);
     }
 
@@ -2372,6 +2372,26 @@ int isLiteralBit(unsigned long lit)
     return 0;
 }
 
+/*-----------------------------------------------------------------*/
+/* jmpTrueOrFalse -                                                */
+/*-----------------------------------------------------------------*/
+static void jmpTrueOrFalse (iCode *ic, symbol *tlbl)
+{
+    // ugly but optimized by peephole
+    if(IC_TRUE(ic)){
+        symbol *nlbl = newiTempLabel(NULL);
+        emitcode("jp", LABEL_STR, nlbl->key+100);                 
+        emitcode("", LABEL_STR ":",tlbl->key+100);
+        emitcode("jp",LABEL_STR,IC_TRUE(ic)->key+100);
+        emitcode("", LABEL_STR ":",nlbl->key+100);
+    }
+    else{
+        emitcode("jp", LABEL_STR, IC_FALSE(ic)->key+100);
+        emitcode("", LABEL_STR ":",tlbl->key+100);
+    }
+    ic->generated = 1;
+}
+
 /*-----------------------------------------------------------------*/
 /* genAnd  - code for and                                          */
 /*-----------------------------------------------------------------*/
@@ -2485,11 +2505,7 @@ static void genAnd (iCode *ic, iCode *ifx)
             // if(left & literal)
             else{
                 if(ifx)
-#if 0
                     jmpTrueOrFalse(ifx, tlbl);
-#else
-               assert(0);
-#endif
                 goto release ;
             }
         }
@@ -3499,7 +3515,7 @@ static void genGenPointerSet (operand *right,
         while (size--) {
             char *l = aopGet(AOP(right),offset,FALSE);
            if (isRegOrLit(AOP(right)) && !IS_GB) {
-               emitcode("ld", "(%s),%s", l);
+               emitcode("ld", "(%s),%s", ptr, l);
            }
            else {
                MOVA(l);
index f59edf6126d1e4806607480653b44ce0211d808f..f19ad5d845f7f2c83fecd2910b87c2c089b1644b 100644 (file)
@@ -68,6 +68,9 @@ static const char *_asmCmd[] = {
 PORT z80_port = {
     "z80",
     "Zilog Z80",               /* Target name */
+    {
+       FALSE,
+    },
     {  
        _asmCmd,
        "-plosgff",             /* Options with debug */
index b0b939045cde64a4f1c555063e237b5300d3ab36..824fac0f2a9705db0d17c860f8a00a65b59cf96e 100644 (file)
@@ -1,28 +1,27 @@
 # Simple Makefile for dhrystone and sdcc
 
-CC = /home/michaelh/projects/sdcc/bin/sdcc
+PROC = gbz80
+PORT = gb
+
+CC = /home/michaelh/projects/gbdk-support/lcc/lcc
 # -DNOENUM is here to make the results more predictable
-CFLAGS = -mgbz80 -v --dumpall
-CFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM -DBROKEN_SDCC=0 -DHZ=100
-LIBDIR = /home/michaelh/projects/sdcc/device/lib/gbz80/
-LD = link-gb
-AS = as-gb
+CFLAGS =
+CFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM
+LIBDIR = /home/michaelh/projects/gbdk-lib/build/
+LD = link-$(PROC)
+LDFLAGS = -v
+AS = as-$(PROC)
 
 OBJ = dhry.o
 
 all: dhry
 
 dhry: $(OBJ)
-       $(LD) -n -- -z -m -k$(LIBDIR) -lz80.lib \
-       -b_CODE=0x200 dhry.gb $(LIBDIR)crt0.o $(OBJ)
-#      cat dhry.ihx | ../../makebin/makebin > dhry.rom
+       $(CC) -o dhry.gb dhry.o
 
 native:
        gcc -g -O2 -DREG= -DNOSTRUCTASSIGN -DNOENUM -o dhry dhry.c
 
-.c.o:
-       $(CC) $(CFLAGS) $<
-
 dhry.c:
 
 clean:
index a893a2022109a638f17074f3c06e9970ec4ca904..27d53aadf2b93379233643b45d3ead9f1db7127f 100644 (file)
 #include <string.h>
 /** For printf */
 #include <stdio.h>
-
-/** Returns the current device time in ticks.  Check HZ in the Makefile
-    as well - HZ ticks = 1 second.
-*/
-unsigned _clock(void);
+/** For clock() */
+#include <time.h>
 
 /** Print the number of t-states this program has been executing for.
     Optional :)
@@ -89,11 +86,7 @@ Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val);
 Boolean Func_2 (char *Str_1_Par_Ref, char *Str_2_Par_Ref);
 Boolean Func_3 (Enumeration Enum_Par_Val);
 
-#if SDCC
-int _main(void) 
-#else
 int main(void)
-#endif
 {
     One_Fifty       Int_1_Loc;
     REG   One_Fifty       Int_2_Loc;
@@ -106,7 +99,7 @@ int main(void)
     REG   int             Number_Of_Runs;
     unsigned runTime;
 
-    //    printf("[dhry]\n");
+    printf("[dhry]\n");
 
     Next_Ptr_Glob = &_r[0];
     Ptr_Glob = &_r[1];
@@ -131,7 +124,7 @@ int main(void)
     /* 32766 is the highest value for a 16 bitter */
     Number_Of_Runs = 32766;
 
-    runTime = _clock();
+    runTime = clock();
 
     /* Main test loop */
     for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) {
@@ -205,7 +198,7 @@ int main(void)
 
     printf("Run_Index = %d\n", Run_Index);
 
-    runTime = _clock() - runTime;
+    runTime = clock() - runTime;
 
     printf ("Execution ends\n");
     printf ("\n");
@@ -261,7 +254,7 @@ int main(void)
     printf ("\n");
 
     printf("Time: %u ticks\n", runTime);
-    printf("Dhrystones/s = %u\n", Number_Of_Runs / (runTime/HZ));
+    printf("Dhrystones/s = %u\n", Number_Of_Runs / (runTime/CLOCKS_PER_SEC));
     printf("MIPS = d/s/1757 = (sigh, need floats...)\n");
     _printTStates();
 }
@@ -309,17 +302,17 @@ void Proc_2 (One_Fifty *Int_Par_Ref)
 
     Int_Loc = *Int_Par_Ref + 10;
     do {
-       DPRINTF(("1\n"));
+       DPRINTF(("1"));
        /* executed once */
        if (Ch_1_Glob == 'A')
            /* then, executed */
            {
-               DPRINTF(("2\n"));
+               DPRINTF(("2"));
                Int_Loc -= 1;
                *Int_Par_Ref = Int_Loc - Int_Glob;
                Enum_Loc = Ident_1;
            } /* if */
-       DPRINTF(("3\n"));
+       DPRINTF(("3"));
     } while (Enum_Loc != Ident_1); /* true */
     DPRINTF(("Proc_2 done.\n"));
 } /* Proc_2 */