From 5fe5cd9eb7dda543f4884df4e6b3d39f10bb35b9 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Wed, 9 Aug 2006 12:30:18 +0000 Subject: [PATCH] * as/z80/assym.c (mlookup): ignore case when looking up mnemonics * as/z80/Makefile.in: added strcmpi.c * as/z80/z80adr.c: added upper case registers and lower case conditionals * support/Util/strcmpi.ch: added with intention to remove from mcs51/hc08 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4327 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 +++++++ as/z80/Makefile.in | 6 +++--- as/z80/assym.c | 5 +++-- as/z80/z80adr.c | 29 +++++++++++++++++++++++++++++ support/Util/strcmpi.c | 35 +++++++++++++++++++++++++++++++++++ support/Util/strcmpi.h | 3 +++ 6 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 support/Util/strcmpi.c create mode 100644 support/Util/strcmpi.h diff --git a/ChangeLog b/ChangeLog index b4f92725..6e8f568c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-09 Maarten Brock + + * as/z80/assym.c (mlookup): ignore case when looking up mnemonics + * as/z80/Makefile.in: added strcmpi.c + * as/z80/z80adr.c: added upper case registers and lower case conditionals + * support/Util/strcmpi.ch: added with intention to remove from mcs51/hc08 + 2006-08-08 Maarten Brock * device/lib/gbz80/asm_strings.s, diff --git a/as/z80/Makefile.in b/as/z80/Makefile.in index a7fc1973..f0295161 100644 --- a/as/z80/Makefile.in +++ b/as/z80/Makefile.in @@ -9,19 +9,19 @@ OBJDIR = obj/$(EXT) SDC = . -SLIBSRC = NewAlloc.c +SLIBSRC = NewAlloc.c strcmpi.c SRC = asdata.c asexpr.c aslex.c aslist.c asmain.c asout.c \ assubr.c assym.c z80adr.c z80ext.c z80mch.c z80pst.c OBJS = $(SRC:%.c=$(OBJDIR)/%.o) -SLIBOBJS = $(SLIBSRC:%.c=$(OBJDIR)/%.o) +SLIBOBJS = $(SLIBSRC:%.c=$(OBJDIR)/%.o) BINS = $(BUILDDIR)/as$(EXT)$(EXEEXT) CFLAGS += $(CPPFLAGS) $(OPTS) -I. -DINDEXLIB -DMLH_MAP -DUNIX -DSDK CFLAGS += -funsigned-char -CFLAGS += -I$(SLIB) +CFLAGS += -I$(SLIB) LDFLAGS += -lm $(EXTRALIBS) diff --git a/as/z80/assym.c b/as/z80/assym.c index 04cbc7da..77e0c268 100644 --- a/as/z80/assym.c +++ b/as/z80/assym.c @@ -14,6 +14,7 @@ #include #include #include "asm.h" +#include "strcmpi.h" /*)Module assym.c * @@ -181,7 +182,7 @@ char *id; h = hash(id); mp = mnehash[h]; while (mp) { - if (symeq(id, mp->m_id)) + if (as_strcmpi(id, mp->m_id) == 0) /* JLH: case insensitive */ return (mp); mp = mp->m_mp; } @@ -382,7 +383,7 @@ register char *p1, *p2; * side effects: * none */ - + int hash(p) register char *p; diff --git a/as/z80/z80adr.c b/as/z80/z80adr.c index d47b8eba..58594b01 100644 --- a/as/z80/z80adr.c +++ b/as/z80/z80adr.c @@ -203,12 +203,21 @@ struct adsym R8[] = { { "h", H|0400 }, { "l", L|0400 }, { "a", A|0400 }, + { "B", B|0400 }, + { "C", C|0400 }, + { "D", D|0400 }, + { "E", E|0400 }, + { "H", H|0400 }, + { "L", L|0400 }, + { "A", A|0400 }, { "", 000 } }; struct adsym R8X[] = { { "i", I|0400 }, { "r", R|0400 }, + { "I", I|0400 }, + { "R", R|0400 }, { "", 000 } }; @@ -217,22 +226,34 @@ struct adsym R16[] = { { "de", DE|0400 }, { "hl", HL|0400 }, { "sp", SP|0400 }, + { "BC", BC|0400 }, + { "DE", DE|0400 }, + { "HL", HL|0400 }, + { "SP", SP|0400 }, #ifndef GAMEBOY { "ix", IX|0400 }, { "iy", IY|0400 }, + { "IX", IX|0400 }, + { "IY", IY|0400 }, #else /* GAMEBOY */ { "hl-", HLD|0400 }, { "hl+", HLI|0400 }, { "hld", HLD|0400 }, { "hli", HLI|0400 }, + { "HL-", HLD|0400 }, + { "HL+", HLI|0400 }, + { "HLD", HLD|0400 }, + { "HLI", HLI|0400 }, #endif /* GAMEBOY */ { "", 000 } }; struct adsym R16X[] = { { "af", AF|0400 }, + { "AF", AF|0400 }, #ifndef GAMEBOY { "af'", AF|0400 }, + { "AF'", AF|0400 }, #endif /* GAMEBOY */ { "", 000 } }; @@ -246,11 +267,19 @@ struct adsym CND[] = { { "Z", Z |0400 }, { "NC", NC|0400 }, { "C", CS|0400 }, + { "nz", NZ|0400 }, + { "z", Z |0400 }, + { "nc", NC|0400 }, + { "c", CS|0400 }, #ifndef GAMEBOY { "PO", PO|0400 }, { "PE", PE|0400 }, { "P", P |0400 }, { "M", M |0400 }, + { "po", PO|0400 }, + { "pe", PE|0400 }, + { "p", P |0400 }, + { "m", M |0400 }, #endif /* GAMEBOY */ { "", 000 } }; diff --git a/support/Util/strcmpi.c b/support/Util/strcmpi.c new file mode 100644 index 00000000..c812ef0a --- /dev/null +++ b/support/Util/strcmpi.c @@ -0,0 +1,35 @@ +/* strcmpi.c */ + +/* + * Compare two strings ignoring case. + * + * Taken from GLIBC 2.2.5. Original code is copyrighted "Free + * Software Foundation" and published under the GNU Lesser General + * Public License. + * + */ + +#include +#include "strcmpi.h" + +int as_strcmpi (const char *s1, const char *s2) +{ + const unsigned char *p1 = (const unsigned char *) s1; + const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2) + return 0; + + do + { + c1 = tolower (*p1++); + c2 = tolower (*p2++); + if (c1 == '\0') + break; + } + while (c1 == c2); + + return c1 - c2; +} + diff --git a/support/Util/strcmpi.h b/support/Util/strcmpi.h new file mode 100644 index 00000000..b284f48a --- /dev/null +++ b/support/Util/strcmpi.h @@ -0,0 +1,3 @@ +/* strcmpi.h */ + +int as_strcmpi (const char *s1, const char *s2); -- 2.30.2