From: michaelh Date: Fri, 3 Aug 2001 06:31:03 +0000 (+0000) Subject: * Fixed alias of -c to -canything X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=57fb57efdae84efae57eb3f23897a0c2c3b598e4;p=fw%2Fsdcc * Fixed alias of -c to -canything * 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 --- diff --git a/device/include/asm/z80/features.h b/device/include/asm/z80/features.h index 3a332105..e3f3b68a 100644 --- a/device/include/asm/z80/features.h +++ b/device/include/asm/z80/features.h @@ -6,4 +6,6 @@ #define _REENTRANT #define _CODE +#define _SDCC_MANGLES_SUPPORT_FUNS 1 + #endif diff --git a/device/lib/_divslong.c b/device/lib/_divslong.c index 8c77bff1..3bd9602a 100644 --- a/device/lib/_divslong.c +++ b/device/lib/_divslong.c @@ -22,6 +22,12 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ +#include + +#if _SDCC_MANGLES_SUPPORT_FUNS +unsigned long _divulong (unsigned long a, unsigned long b); +#endif + long _divslong (long a, long b) { long r; diff --git a/device/lib/_modslong.c b/device/lib/_modslong.c index 1d5625d0..9eb09f65 100644 --- a/device/lib/_modslong.c +++ b/device/lib/_modslong.c @@ -21,6 +21,13 @@ You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ + +#include + +#if _SDCC_MANGLES_SUPPORT_FUNS +unsigned long _modulong (unsigned long a, unsigned long b); +#endif + long _modslong (long a, long b) { long r; diff --git a/device/lib/_mulslong.c b/device/lib/_mulslong.c index a4571dd0..af24958b 100644 --- a/device/lib/_mulslong.c +++ b/device/lib/_mulslong.c @@ -21,6 +21,13 @@ You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ + +#include + +#if _SDCC_MANGLES_SUPPORT_FUNS +unsigned long _mululong (unsigned long a, unsigned long b); +#endif + long _mulslong (long a, long b) { long r; diff --git a/device/lib/_mululong.c b/device/lib/_mululong.c index 19a1352a..77eb82df 100644 --- a/device/lib/_mululong.c +++ b/device/lib/_mululong.c @@ -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 diff --git a/device/lib/z80/Makefile b/device/lib/z80/Makefile index 753ddd26..7cae7cf0 100644 --- a/device/lib/z80/Makefile +++ b/device/lib/z80/Makefile @@ -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) diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 6451241d..9c9e63a4 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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; diff --git a/src/z80/gen.c b/src/z80/gen.c index 77764b7f..8c3df03f 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -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"); diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 3d964752..fce6009e 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -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}, diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index e92f339f..795eb9fe 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -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." } }; /* diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index 8fcfa411..045fe6f3 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -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. diff --git a/support/regression/tests/muldiv.c b/support/regression/tests/muldiv.c index c66c7057..a8641d21 100644 --- a/support/regression/tests/muldiv.c +++ b/support/regression/tests/muldiv.c @@ -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, */