From: Knut S. O. <bir...@an...> - 2016-04-15 09:24:13
|
Hi again. I ended up fixing the Open Watcom build as well the other day, adding librarian support to the makefile and fixing rules for perl generated sources. Also enabled using the automatic borland/watcom dependencies, optional debug info, and adjusted the clean rule a little. OW v1.9 has trouble with switching on 64-bit integers, so I had to convert three minor switch statements to if statements. It also have some issues comparing default integers and 64-bit integers, or something along those lines, so I had to apply UINT64_C() to a couple of constants too. Kind Regards, bird. Signed-off-by: Knut St. Osmundsen<bir...@an...> --- Mkfiles/openwcom.mak | 69 +++++++++++++++++++++++++++++++++------------------- assemble.c | 8 ++---- output/codeview.c | 5 ++-- parser.c | 24 ++++++------------ 4 files changed, 57 insertions(+), 49 deletions(-) diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 4382536..4e1681f 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -1,33 +1,42 @@ # -*- makefile -*- # -# Makefile for building NASM using OpenWatcom +# Makefile (wmake) for building NASM using OpenWatcom # cross-compile on a DOS/Win32/OS2/Linux platform host # top_srcdir = . srcdir = . -VPATH = .;$(srcdir)/output;$(srcdir)/lib +VPATH = .;$(srcdir)/output;$(srcdir)/lib;$(srcdir)/stdlib;$(srcdir)/nasmlib prefix = C:\Program Files\NASM exec_prefix = $(prefix) bindir = $(prefix)\bin mandir = $(prefix)\man +!if "$(DEBUG)" == "1" +CDEBUG = -d2 -hd +LDEBUG = debug dwarf +!else +CDEBUG = +LDEBUG = +!endif + CC = *wcl386 -DEBUG = -CFLAGS = -zq -6 -ox -wx -ze -fpi $(DEBUG) +CFLAGS = -zq -6 -ox -wx -ze -fpi $(CDEBUG) BUILD_CFLAGS = $(CFLAGS) $(%TARGET_CFLAGS) INTERNAL_CFLAGS = -I$(srcdir) -I. -DHAVE_CONFIG_H ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS) LD = *wlink -LDEBUG = LDFLAGS = op quiet $(%TARGET_LFLAGS) $(LDEBUG) LIBS = +AR = *wlib +ARFLAGS = -n -q -b PERL = perl -I$(srcdir)/perllib STRIP = wstrip # Binary suffixes O = obj +L = lib X = .exe # WMAKE errors out if a suffix is declared more than once, including @@ -40,7 +49,7 @@ X = .exe # Needed to find C files anywhere but in the current directory .c : $(VPATH) -.c.$(O): +.c.$(O): .AUTODEPEND @set INCLUDE= $(CC) -c $(ALL_CFLAGS) -fo=$^@ $[@ @@ -102,11 +111,14 @@ linux386: .SYMBOLIC all: config.h perlreq nasm$(X) ndisasm$(X) .SYMBOLIC # cd rdoff && $(MAKE) all -nasm$(X): $(NASM) - $(LD) $(LDFLAGS) name nasm$(X) file {$(NASM)} $(LIBS) +nasm$(X): $(NASM) nasm.$(L) + $(LD) $(LDFLAGS) name nasm$(X) file {$(NASM)} library {nasm.$(L) $(LIBS)} ndisasm$(X): $(NDISASM) - $(LD) $(LDFLAGS) name ndisasm$(X) file {$(NDISASM)} $(LIBS) + $(LD) $(LDFLAGS) name ndisasm$(X) file {$(NDISASM)} library {nasm.$(L) $(LIBS)} + +nasm.$(L): $(LIBOBJ) + $(AR) $(ARFLAGS) -o $@ +$(LIBOBJ: = +) # These source files are automagically generated from a single # instruction-table file by a Perl script. They're distributed, @@ -115,18 +127,23 @@ ndisasm$(X): $(NDISASM) insns.pl: insns-iflags.pl -iflag.c iflag.h: insns.dat insns.pl - $(PERL) $(srcdir)/insns.pl -t $(srcdir)/insns.dat -insnsb.c: insns.dat insns.pl - $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat -insnsa.c: insns.dat insns.pl - $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat -insnsd.c: insns.dat insns.pl - $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat -insnsi.h: insns.dat insns.pl - $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat -insnsn.c: insns.dat insns.pl - $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat +INSDEP = insns.dat insns.pl insns-iflags.pl + +iflag.c: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -fc $(srcdir)/insns.dat +iflaggen.h: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -fh $(srcdir)/insns.dat +insnsb.c: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -b $(srcdir)/insns.dat +insnsa.c: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -a $(srcdir)/insns.dat +insnsd.c: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -d $(srcdir)/insns.dat +insnsi.h: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -i $(srcdir)/insns.dat +insnsn.c: $(INSDEP) + $(PERL) $(srcdir)/insns.pl -n $(srcdir)/insns.dat + # These files contains all the standard macros that are derived from # the version number. @@ -189,13 +206,15 @@ PERLREQ = pptok.ph macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c & tokhash.c tokens.h pptok.h pptok.c & directiv.c directiv.h & version.h version.mac & - iflag.c iflag.h + iflag.c iflaggen.h perlreq: $(PERLREQ) .SYMBOLIC clean: .SYMBOLIC - rm -f *.$(O) *.s *.i - rm -f lib/*.$(O) lib/*.s lib/*.i - rm -f output/*.$(O) output/*.s output/*.i + rm -f *.$(O) *.$(L) *.s *.i *.err + rm -f lib/*.$(O) lib/*.s lib/*.i lib/*.err + rm -f output/*.$(O) output/*.s output/*.i output/*.err + rm -f nasmlib/*.$(O) nasmlib/*.$(L) nasmlib/*.s nasmlib/*.i nasmlib/*.err + rm -f stdlib/*.$(O) stdlib/*.$(L) stdlib/*.s stdlib/*.i stdlib/*.err rm -f config.h config.log config.status rm -f nasm$(X) ndisasm$(X) # cd rdoff && $(MAKE) clean diff --git a/assemble.c b/assemble.c index 0fe323c..57ad6f3 100644 --- a/assemble.c +++ b/assemble.c @@ -2153,14 +2153,10 @@ static uint8_t get_broadcast_num(opflags_t opflags, opflags_t brsize) nasm_error(ERR_FATAL, "size of broadcasting element is greater than 64 bits"); - switch (opsize) { - case BITS64: + if (opsize == BITS64) brcast_num = BITS64 / brsize; - break; - default: + else brcast_num = (opsize / BITS128) * (BITS64 / brsize) * 2; - break; - } return brcast_num; } diff --git a/output/codeview.c b/output/codeview.c index a63fd63..8ddc692 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -364,6 +364,7 @@ static void register_reloc(struct coff_Section *const sect, { struct coff_Reloc *r; struct coff_Section *sec; + uint32_t i; r = *sect->tail = nasm_malloc(sizeof(struct coff_Reloc)); sect->tail = &r->next; @@ -375,7 +376,7 @@ static void register_reloc(struct coff_Section *const sect, r->type = type; r->symbol = 0; - for (int i = 0; i < coff_nsects; i++) { + for (i = 0; i < (uint32_t)coff_nsects; i++) { sec = coff_sects[i]; if (!strcmp(sym, sec->name)) { return; @@ -384,7 +385,7 @@ static void register_reloc(struct coff_Section *const sect, } saa_rewind(coff_syms); - for (uint32_t i = 0; i < coff_nsyms; i++) { + for (i = 0; i < coff_nsyms; i++) { struct coff_Symbol *s = saa_rstruct(coff_syms); r->symbol++; if (s->strpos == -1 && !strcmp(sym, s->name)) { diff --git a/parser.c b/parser.c index 6210cc6..5c6b594 100644 --- a/parser.c +++ b/parser.c @@ -214,18 +214,15 @@ static bool parse_braces(decoflags_t *decoflags) } *decoflags |= VAL_OPMASK(nasm_regvals[tokval.t_integer]); } else if (i == TOKEN_DECORATOR) { - switch (tokval.t_integer) { - case BRC_Z: + if (tokval.t_integer == BRC_Z) { /* * according to AVX512 spec, only zeroing/merging decorator * is supported with opmask */ *decoflags |= GEN_Z(0); - break; - default: + } else { nasm_error(ERR_NONFATAL, "{%s} is not an expected decorator", tokval.t_charptr); - break; } } else if (i == ',' || i == TOKEN_EOS){ break; @@ -1023,9 +1020,9 @@ is_expression: op->type |= SBYTEDWORD; if ((uint16_t) (n + 128) <= 255) op->type |= SBYTEWORD; - if (n <= 0xFFFFFFFF) + if (n <= UINT64_C(0xFFFFFFFF)) op->type |= UDWORD; - if (n + 0x80000000 <= 0xFFFFFFFF) + if (n + UINT64_C(0x80000000) <= UINT64_C(0xFFFFFFFF)) op->type |= SDWORD; } } @@ -1036,18 +1033,13 @@ is_expression: * of previous operand. */ opnum--; op--; - switch (value->value) { - case BRC_RN: - case BRC_RU: - case BRC_RD: - case BRC_RZ: - case BRC_SAE: + if ( value->value == BRC_RN || value->value == BRC_RU + || value->value == BRC_RD || value->value == BRC_RZ + || value->value == BRC_SAE) { op->decoflags |= (value->value == BRC_SAE ? SAE : ER); result->evex_rm = value->value; - break; - default: + } else { nasm_error(ERR_NONFATAL, "invalid decorator"); - break; } } else { /* it's a register */ opflags_t rs; -- 2.6.2.windows.1 |