* src/SDCCmain.c (linkEdit): Added support for passing a legacy command line through...
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 13 Oct 2001 19:25:11 +0000 (19:25 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 13 Oct 2001 19:25:11 +0000 (19:25 +0000)
* src/mcs51/main.c (_linkCmd): Added bin path to command.

* src/SDCCmain.c (initValues): Added support for when it it called just to link.

* as/mcs51/lklibr.c (libfil;): Turned off 'library file' message.

* src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc.

* support/regression/tests/longor.c: Added.

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

ChangeLog
as/mcs51/lklibr.c
src/SDCCmacro.c
src/SDCCmain.c
src/SDCCutil.c
src/mcs51/main.c
src/z80/gen.c
src/z80/mappings.i
support/regression/Makefile

index e7abfd352b2019dc5f51d2dd8bbfb21ef7ef03e9..c2d57d24729f0dc38a8ab5f080457b0218955b98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2001-10-13  Michael Hope  <michaelh@juju.net.nz>
 
+       * src/SDCCmain.c (linkEdit): Added support for passing a legacy command line through the processor.
+
+       * src/mcs51/main.c (_linkCmd): Added bin path to command.
+
+       * src/SDCCmain.c (initValues): Added support for when it it called just to link.
+
+       * as/mcs51/lklibr.c (libfil;): Turned off 'library file' message.
+
        * src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc.
 
        * support/regression/tests/longor.c: Added.
index b4e287ef8a308d9796da06198b6b947ada480bbb..cadcbfa1b7e3d887297ad419d0436593d0a1bfcd 100644 (file)
@@ -207,7 +207,6 @@ char *libfil;
                lbnh->libfil = (char *) new (strlen(libfil) + 1);
                strcpy(lbnh->libfil,libfil);
                lbnh->libspc = str;
-               fprintf(stderr,"library file %s\n",str);
        } else {
                free(str);
        }
index eb2b49c107229aa515cd3b35daccb2bc779f5855..b71c20da1a8802714dda4e32ba098ebca2dbc442 100644 (file)
@@ -36,7 +36,9 @@ _evalMacros(char *apinto, hTab *pvals, const char *pfrom)
   bool fdidsomething = FALSE;
   char *pinto = apinto;
 
-  assert(pinto && pvals && pfrom);
+  assert(pinto);
+  assert(pvals);
+  assert(pfrom);
 
   while (*pfrom)
     {
index 9ea904fa3f5f1d9c98651aeb7846b4b5d53bc2da..be35a87756efcca74defcbc7ef6003617840badc 100644 (file)
@@ -1164,7 +1164,9 @@ linkEdit (char **envp)
 
   if (port->linker.cmd)
     {
-      buildCmdLine (buffer, port->linker.cmd, srcFileName, NULL, NULL, NULL);
+      char buffer2[PATH_MAX];
+      buildCmdLine (buffer2, port->linker.cmd, srcFileName, NULL, NULL, NULL);
+      buildCmdLine2 (buffer, buffer2);
     }
   else
     {
@@ -1449,10 +1451,11 @@ initValues (void)
 {
   populateMainValues (_baseValues);
   setMainValue ("port", port->target);
-  setMainValue ("fullsrcfilename", fullSrcFileName);
-  setMainValue ("srcfilename", srcFileName);
   setMainValue ("objext", port->linker.rel_ext);
   setMainValue ("asmext", port->assembler.file_ext);
+
+  setMainValue ("fullsrcfilename", fullSrcFileName ? fullSrcFileName : "fullsrcfilename");
+  setMainValue ("srcfilename", srcFileName ? srcFileName : "srcfilename");
 }
 
 /*
@@ -1505,11 +1508,11 @@ main (int argc, char **argv, char **envp)
       exit (0);
     }
 
+  initValues ();
+  _discoverPaths (argv[0]);
+
   if (srcFileName)
     {
-      initValues ();
-      _discoverPaths (argv[0]);
-
       preProcess (envp);
 
       initMem ();
index 73b0b7cc4d00610a70b559daf57ea4fc05f43b68..a4c9d932c776bf8404d383fdff1eecbff54720b8 100644 (file)
@@ -271,13 +271,20 @@ static hTab *_mainValues;
 void
 setMainValue (const char *pname, const char *pvalue)
 {
+  assert(pname);
+  assert(pvalue);
+
   shash_add (&_mainValues, pname, pvalue);
 }
 
 void
 buildCmdLine2 (char *pbuffer, const char *pcmd)
 {
-  char *poutcmd = msprintf(_mainValues, pcmd);
+  char *poutcmd;
+  assert(pbuffer && pcmd);
+  assert(_mainValues);
+
+  poutcmd = msprintf(_mainValues, pcmd);
   strcpy(pbuffer, poutcmd);
 }
 
index b23a03d0e15ad7db0455d61a16b8fa466d401014..8731cfb791a312f57f9deedf8660dcd3e2c69d2f 100644 (file)
@@ -128,7 +128,7 @@ _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
 */
 static const char *_linkCmd[] =
 {
-  "aslink", "-nf", "$1", NULL
+  "{bindir}{sep}aslink", "-nf", "$1", NULL
 };
 
 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
index 6bffec3cca9439c1da0ba5f1bc9f4dd5b056551b..2f1f0e219363e61e5fb5029e0206f8358e7b7e56 100644 (file)
@@ -135,6 +135,12 @@ static char **_fTmp;
 
 extern FILE *codeOutFile;
 
+enum
+  {
+    INT8MIN = -128,
+    INT8MAX = 127
+  };
+
 /** Enum covering all the possible register pairs.
  */
 typedef enum
@@ -536,10 +542,10 @@ aopForSym (iCode * ic, symbol * sym, bool result, bool requires_a)
   if (sym->onStack || sym->iaccess)
     {
       /* The pointer that is used depends on how big the offset is.
-         Normally everything is AOP_STK, but for offsets of < -127 or
-         > 128 on the Z80 an extended stack pointer is used.
+         Normally everything is AOP_STK, but for offsets of < -128 or
+         > 127 on the Z80 an extended stack pointer is used.
       */
-      if (IS_Z80 && (options.ommitFramePtr || sym->stack < -127 || sym->stack > (int)(128-getSize (sym->type))))
+      if (IS_Z80 && (options.ommitFramePtr || sym->stack < INT8MIN || sym->stack > (int)(INT8MAX-getSize (sym->type))))
         {
           emitDebug ("; AOP_EXSTK for %s", sym->rname);
           sym->aop = aop = newAsmop (AOP_EXSTK);
@@ -1082,7 +1088,7 @@ fetchLitPair (PAIR_ID pairId, asmop * left, int offset)
                      adjustPair (pair, &_G.pairs[pairId].offset, offset);
                      return;
                    }
-                 if (pairId == PAIR_IY && abs (offset) < 127)
+                 if (pairId == PAIR_IY && (offset >= INT8MIN && offset <= INT8MAX))
                    {
                      return;
                    }
@@ -1158,6 +1164,22 @@ fetchHL (asmop * aop)
   fetchPair (PAIR_HL, aop);
 }
 
+static void
+setupPairFromSP (PAIR_ID id, int offset)
+{
+  wassertl (id == PAIR_HL, "Setup relative to SP only implemented for HL");
+
+  if (offset < INT8MIN || offset > INT8MAX)
+    {
+      emit2 ("ld hl,!immedword", offset);
+      emit2 ("add hl,sp");
+    }
+  else
+    {
+      emit2 ("!ldahlsp", offset);
+    }
+}
+
 static void
 setupPair (PAIR_ID pairId, asmop * aop, int offset)
 {
@@ -1215,7 +1237,7 @@ setupPair (PAIR_ID pairId, asmop * aop, int offset)
          }
        else
          {
-           emit2 ("!ldahlsp", abso + _G.stack.pushed);
+            setupPairFromSP (PAIR_HL, abso + _G.stack.pushed);
          }
        _G.pairs[pairId].offset = abso;
        break;
@@ -2579,7 +2601,9 @@ genFunction (iCode * ic)
   /* adjust the stack for the function */
   _G.stack.last = sym->stack;
 
-  if (sym->stack)
+  if (sym->stack && IS_GB && sym->stack > -INT8MIN)
+    emit2 ("!enterxl", sym->stack);
+  else if (sym->stack)
     emit2 ("!enterx", sym->stack);
   else
     emit2 ("!enter");
@@ -2605,7 +2629,11 @@ genEndFunction (iCode * ic)
 
       /* PENDING: calleeSave */
 
-      if (_G.stack.offset)
+      if (_G.stack.offset && IS_GB && _G.stack.offset > INT8MAX)
+        {
+          emit2 ("!leavexl", _G.stack.offset);
+        }
+      else if (_G.stack.offset)
         {
           emit2 ("!leavex", _G.stack.offset);
         }
@@ -5566,21 +5594,19 @@ genAddrOf (iCode * ic)
          spillCached ();
          if (sym->stack <= 0)
            {
-             emit2 ("!ldahlsp", sym->stack + _G.stack.pushed + _G.stack.offset);
+              setupPairFromSP (PAIR_HL, sym->stack + _G.stack.pushed + _G.stack.offset);
            }
          else
            {
-             emit2 ("!ldahlsp", sym->stack + _G.stack.pushed + _G.stack.offset + _G.stack.param_offset);
+              setupPairFromSP (PAIR_HL, sym->stack + _G.stack.pushed + _G.stack.offset + _G.stack.param_offset);
            }
-         emit2 ("ld d,h");
-         emit2 ("ld e,l");
+          commitPair (AOP (IC_RESULT (ic)), PAIR_HL);
        }
       else
        {
          emit2 ("ld de,!hashedstr", sym->rname);
+          commitPair (AOP (IC_RESULT (ic)), PAIR_DE);
        }
-      aopPut (AOP (IC_RESULT (ic)), "e", 0);
-      aopPut (AOP (IC_RESULT (ic)), "d", 1);
     }
   else
     {
@@ -5598,8 +5624,7 @@ genAddrOf (iCode * ic)
        {
          emit2 ("ld hl,#%s", sym->rname);
        }
-      aopPut (AOP (IC_RESULT (ic)), "l", 0);
-      aopPut (AOP (IC_RESULT (ic)), "h", 1);
+      commitPair (AOP (IC_RESULT (ic)), PAIR_HL);
     }
   freeAsmop (IC_RESULT (ic), NULL, ic);
 }
index d2887dc19a6f42205bc416525cd217368248b029..319afdd1190fe44d3e1a0878911cc15601fc7d86 100644 (file)
@@ -15,10 +15,20 @@ static const ASM_MAPPING _asxxxx_gb_mapping[] = {
     { "enter", "" },
     { "enterx", 
       "lda sp,-%d(sp)" },
+    { "enterxl",
+                "ld hl,#-%d\n"
+                "\tadd\thl,sp\n"
+                "\tld\tsp,hl"
+    },
     { "leave", ""
     },
     { "leavex", "lda sp,%d(sp)"
     },
+    { "leavexl",
+                "ld hl,#%d\n"
+                "\tadd\thl,sp\n"
+                "\tld\tsp,hl"
+    },
     { "pusha", 
       "push af\n"
       "\tpush bc\n"
index 39b1a9c629f238e38458c4796c5a592e1234ea3b..32e93fbf94e41216f3f4d627f168ff854f838428 100644 (file)
@@ -101,6 +101,7 @@ PORT_RESULTS = $(ALL_TESTS:$(TESTS_DIR)/%.c=$(PORT_RESULTS_DIR)/%.out)
 SDCC_DIR = ../..
 SDCC_EXTRA_DIR = ../../../sdcc-extra
 
+
 # Defaults.  Override in spec.mk if required.
 # Path to SDCC
 SDCC = $(SDCC_DIR)/bin/sdcc