* Fixed alias of -c to -canything
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 3 Aug 2001 06:31:03 +0000 (06:31 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 3 Aug 2001 06:31:03 +0000 (06:31 +0000)
* Added long support for mul and div to the z80 port.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1125 4a8a32a2-be11-0410-ad9d-d568d2c75423

12 files changed:
device/include/asm/z80/features.h
device/lib/_divslong.c
device/lib/_modslong.c
device/lib/_mulslong.c
device/lib/_mululong.c
device/lib/z80/Makefile
src/SDCCmain.c
src/z80/gen.c
src/z80/ralloc.c
support/Util/SDCCerr.c
support/Util/SDCCerr.h
support/regression/tests/muldiv.c

index 3a33210512c87cafe9ba8437f7d4c23f25c3cc0b..e3f3b68a1b3d913100762abdb14e4ac5c95c0f8f 100644 (file)
@@ -6,4 +6,6 @@
 #define _REENTRANT
 #define _CODE
 
+#define _SDCC_MANGLES_SUPPORT_FUNS     1
+
 #endif
index 8c77bff1e829047632e800d739c53d7e2a19a142..3bd9602aab6a814f528869b6a4d352f68b36095d 100644 (file)
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 
+#include <sdcc-lib.h>
+
+#if _SDCC_MANGLES_SUPPORT_FUNS
+unsigned long _divulong (unsigned long a, unsigned long b);
+#endif
+
 long _divslong (long a, long b)
 {
        long r;
index 1d5625d06547e0db6ec44ce2fb8bc1ef21628db0..9eb09f65faa660b639c2bb34da9054a09842b54c 100644 (file)
    You are forbidden to forbid anyone else to use, share and improve
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
+
+#include <sdcc-lib.h>
+
+#if _SDCC_MANGLES_SUPPORT_FUNS
+unsigned long _modulong (unsigned long a, unsigned long b);
+#endif
+
 long  _modslong (long a, long b)
 {
        long r;
index a4571dd0ecc8c233ac7fc6c8d627ccc8300a79e0..af24958b3cfb3e613b8053ef10e07436eab8736e 100644 (file)
    You are forbidden to forbid anyone else to use, share and improve
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
+
+#include <sdcc-lib.h>
+
+#if _SDCC_MANGLES_SUPPORT_FUNS
+unsigned long _mululong (unsigned long a, unsigned long b);
+#endif
+
 long _mulslong (long a, long b)
 {
        long r;
index 19a1352a3c02fd67af4fea4e06ad776bd3e84f14..77eb82df582663c7ff1792548615cf07a5c1fcb7 100644 (file)
@@ -34,6 +34,8 @@ union bil {
 } ;
 #if defined(SDCC_MODEL_LARGE) || defined (SDCC_ds390)
 #define bcast(x) ((union bil _xdata  *)&(x))
+#elif defined(__z80) || defined(__gbz80)
+#define bcast(x) ((union bil *)&(x))
 #else
 #define bcast(x) ((union bil _near *)&(x))
 #endif
index 753ddd2683617437db370df16d05edb9c132d50a..7cae7cf0acb38f43d1413c67124926ce49091881 100644 (file)
@@ -5,7 +5,7 @@ TOPDIR = ../../..
 SCC = $(TOPDIR)/bin/sdcc -mz80
 SAS = $(TOPDIR)/bin/as-z80
 
-OBJ = div.o mul.o putchar.o printf.o shift.o # asm_strings.o string.s
+OBJ = div.o mul.o putchar.o printf.o shift.o stubs.o # asm_strings.o string.s
 LIB = z80.lib
 CC = $(SCC)
 AS = $(SAS)
index 6451241d567f997e34d90608470c7e7f8d902a4b..9c9e63a41bd434cd2780369b35d7655ed959080e 100644 (file)
@@ -585,6 +585,15 @@ getIntArg(const char *szStart, char **argv, int *pi, int argc)
     return (int)floatFromVal(constVal(getStringArg(szStart, argv, pi, argc)));
 }
 
+static void
+verifyShortOption(const char *opt)
+{
+  if (strlen(opt) != 2)
+    {
+      werror (W_EXCESS_SHORT_OPTIONS, opt);
+    }
+}
+
 static bool
 tryHandleUnsupportedOpt(char **argv, int *pi)
 {
@@ -644,22 +653,29 @@ tryHandleSimpleOpt(char **argv, int *pi)
                 }
 
             for (i = 0; i < LENGTH(optionsTable); i++) 
-                {
-                    if (optionsTable[i].shortOpt == shortOpt || 
-                        (longOpt && optionsTable[i].longOpt && strcmp(optionsTable[i].longOpt, longOpt) == 0))
-                        {
-                            // If it is a flag then we can handle it here
-                            if (optionsTable[i].pparameter != NULL) 
-                                {
-                                    (*optionsTable[i].pparameter)++;
-                                    return 1;
-                                }
-                            else {
-                                // Not a flag.  Handled manually later.
-                                return 0;
-                            }
-                        }
-                }
+              {
+                if (optionsTable[i].shortOpt == shortOpt ||
+                    (longOpt && optionsTable[i].longOpt && 
+                     strcmp(optionsTable[i].longOpt, longOpt) == 0))
+                  {
+
+                    // If it is a flag then we can handle it here
+                    if (optionsTable[i].pparameter != NULL) 
+                      {
+                        if (optionsTable[i].shortOpt == shortOpt)
+                          {
+                            verifyShortOption(argv[*pi]);
+                          }
+
+                        (*optionsTable[i].pparameter)++;
+                        return 1;
+                      }
+                    else {
+                      // Not a flag.  Handled manually later.
+                      return 0;
+                    }
+                  }
+              }
             // Didn't find in the table
             return 0;
         }
@@ -864,6 +880,8 @@ parseCmdLine (int argc, char **argv)
          switch (argv[i][1])
            {
            case 'h':
+              verifyShortOption(argv[i]);
+
              printUsage ();
              exit (0);
              break;
@@ -874,6 +892,8 @@ parseCmdLine (int argc, char **argv)
              break;
 
            case 'c':
+              verifyShortOption(argv[i]);
+
              options.cc_only = 1;
              break;
 
@@ -906,6 +926,8 @@ parseCmdLine (int argc, char **argv)
              break;
 
            case 'v':
+              verifyShortOption(argv[i]);
+
              printVersionInfo ();
              exit (0);
              break;
index 77764b7fcb75163655bbb47f27bcdc50d293464a..8c3df03facc4074631cce92f31e7204cac3732fa 100644 (file)
@@ -4269,6 +4269,39 @@ genRLC (iCode * ic)
   wassert (0);
 }
 
+/*-----------------------------------------------------------------*/
+/* genGetHbit - generates code get highest order bit               */
+/*-----------------------------------------------------------------*/
+static void
+genGetHbit (iCode * ic)
+{
+  operand *left, *result;
+  left = IC_LEFT (ic);
+  result = IC_RESULT (ic);
+  aopOp (left, ic, FALSE, FALSE);
+  aopOp (result, ic, FALSE, FALSE);
+
+  /* get the highest order byte into a */
+  emit2("ld a,%s", aopGet (AOP (left), AOP_SIZE (left) - 1, FALSE));
+
+  if (AOP_TYPE (result) == AOP_CRY)
+    {
+      emit2 ("rl a");
+      outBitC (result);
+    }
+  else
+    {
+      emit2 ("rlc a");
+      /* PENDING: For re-target. */
+      emit2 ("and a,#1");
+      outAcc (result);
+    }
+
+
+  freeAsmop (left, NULL, ic);
+  freeAsmop (result, NULL, ic);
+}
+
 /*-----------------------------------------------------------------*/
 /* shiftR2Left2Result - shift right two bytes from left to result  */
 /*-----------------------------------------------------------------*/
@@ -5692,8 +5725,9 @@ genZ80Code (iCode * lic)
          break;
 
        case GETHBIT:
-         emit2 ("; genHBIT");
-         wassert (0);
+         emit2 ("; genGetHBIT");
+         genGetHbit (ic);
+          break;
 
        case LEFT_OP:
          emit2 ("; genLeftShift");
index 3d964752649cfba41717aa4db79d31c2afad6499..fce6009e6398398623c916d78d20edb2221f68a9 100644 (file)
@@ -105,8 +105,6 @@ static regs _z80_regs[] =
   {REG_GPR, B_IDX, "b", 1},
   {REG_GPR, E_IDX, "e", 1},
   {REG_GPR, D_IDX, "d", 1},
-    /*    { REG_GPR, L_IDX , "l", 1 },
-       { REG_GPR, H_IDX , "h", 1 }, */
 #if DEBUG_FAKE_EXTRA_REGS
   {REG_GPR, M_IDX, "m", 1},
   {REG_GPR, N_IDX, "n", 1},
index e92f339f304a4111c11f6ed56c7117d5c3a4e19c..795eb9fe27dffdec9c2b8f5ca7ce225f76748ee1 100644 (file)
@@ -357,6 +357,8 @@ struct
     "newline in string constant" },
 { E_CANNOT_USE_GENERIC_POINTER, ERROR_LEVEL_ERROR,
     "cannot use generic pointer %s to initialize %s" },
+{ W_EXCESS_SHORT_OPTIONS, ERROR_LEVEL_WARNING,
+    "Only one short option can be specified at a time.  Rest of %s ignored." }
 };
 
 /*
index 8fcfa411514d37dec419a34b22524cdb509161df..045fe6f3c7a77eabf2ab5bfa75a2243761f8b290 100644 (file)
@@ -167,6 +167,7 @@ SDCCERR - SDCC Standard error handler
 #define W_STRAY_BACKSLASH 149
 #define W_NEWLINE_IN_STRING 150 
 #define E_CANNOT_USE_GENERIC_POINTER 151
+#define  W_EXCESS_SHORT_OPTIONS 152
 
 /** Describes the maximum error level that will be logged.  Any level
  *  includes all of the levels listed after it.
index c66c70574974ef4917c32c89eaa5196af5f28fc5..a8641d218e60c0906b462204fb5ca7e1d112010b 100644 (file)
@@ -1,6 +1,6 @@
 /** Simple test for the mul/div/mod operations.
 
-    type: int, char, short
+    type: int, char, short, long
     storage: static,
     attr: volatile,
 */