From f394f02423f3b9490b60a5f603ebc4af0041b573 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sat, 13 Oct 2001 19:25:11 +0000 Subject: [PATCH] * 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. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1396 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 8 ++++++ as/mcs51/lklibr.c | 1 - src/SDCCmacro.c | 4 ++- src/SDCCmain.c | 15 ++++++---- src/SDCCutil.c | 9 +++++- src/mcs51/main.c | 2 +- src/z80/gen.c | 55 +++++++++++++++++++++++++++---------- src/z80/mappings.i | 10 +++++++ support/regression/Makefile | 1 + 9 files changed, 80 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7abfd35..c2d57d24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2001-10-13 Michael Hope + * 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. diff --git a/as/mcs51/lklibr.c b/as/mcs51/lklibr.c index b4e287ef..cadcbfa1 100644 --- a/as/mcs51/lklibr.c +++ b/as/mcs51/lklibr.c @@ -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); } diff --git a/src/SDCCmacro.c b/src/SDCCmacro.c index eb2b49c1..b71c20da 100644 --- a/src/SDCCmacro.c +++ b/src/SDCCmacro.c @@ -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) { diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 9ea904fa..be35a877 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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 (); diff --git a/src/SDCCutil.c b/src/SDCCutil.c index 73b0b7cc..a4c9d932 100644 --- a/src/SDCCutil.c +++ b/src/SDCCutil.c @@ -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); } diff --git a/src/mcs51/main.c b/src/mcs51/main.c index b23a03d0..8731cfb7 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -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 */ diff --git a/src/z80/gen.c b/src/z80/gen.c index 6bffec3c..2f1f0e21 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -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); } diff --git a/src/z80/mappings.i b/src/z80/mappings.i index d2887dc1..319afdd1 100644 --- a/src/z80/mappings.i +++ b/src/z80/mappings.i @@ -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" diff --git a/support/regression/Makefile b/support/regression/Makefile index 39b1a9c6..32e93fbf 100644 --- a/support/regression/Makefile +++ b/support/regression/Makefile @@ -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 -- 2.30.2