From c9f57c24d0761693cc44a0e6d205c484dd9dbf52 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 19 Sep 2002 04:27:01 +0000 Subject: [PATCH] Fixes from Bart Oldeman --- CHANGES | 5 +++++ disasm.c | 22 +++++++++++----------- output/outobj.c | 3 ++- parser.c | 3 ++- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 1d1fb66e..507cd7e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +0.98.36 +------- +* Fix signed/unsigned problems. +* Fix JMP FAR label and CALL FAR label. + 0.98.35 ------- * Fix build failure on 16-bit DOS (Makefile.bc3 workaround for compiler bug.) diff --git a/disasm.c b/disasm.c index 811051e0..6daab423 100644 --- a/disasm.c +++ b/disasm.c @@ -154,7 +154,7 @@ static unsigned char *do_ea (unsigned char *data, int modrm, int asize, case 2: op->segment |= SEG_DISP16; op->offset = *data++; - op->offset |= (*data++) << 8; + op->offset |= ((unsigned) *data++) << 8; break; } return data; @@ -229,7 +229,7 @@ static unsigned char *do_ea (unsigned char *data, int modrm, int asize, case 2: op->segment |= SEG_DISP32; op->offset = *data++; - op->offset |= (*data++) << 8; + op->offset |= ((unsigned) *data++) << 8; op->offset |= ((long) *data++) << 16; op->offset |= ((long) *data++) << 24; break; @@ -316,11 +316,11 @@ static int matches (struct itemplate *t, unsigned char *data, int asize, ins->oprs[c-024].offset = *data++; if (c >= 030 && c <= 032) { ins->oprs[c-030].offset = *data++; - ins->oprs[c-030].offset |= (*data++ << 8); + ins->oprs[c-030].offset |= (((unsigned) *data++) << 8); } if (c >= 034 && c <= 036) { ins->oprs[c-034].offset = *data++; - ins->oprs[c-034].offset |= (*data++ << 8); + ins->oprs[c-034].offset |= (((unsigned) *data++) << 8); if (osize == 32) { ins->oprs[c-034].offset |= (((long) *data++) << 16); ins->oprs[c-034].offset |= (((long) *data++) << 24); @@ -330,13 +330,13 @@ static int matches (struct itemplate *t, unsigned char *data, int asize, } if (c >= 040 && c <= 042) { ins->oprs[c-040].offset = *data++; - ins->oprs[c-040].offset |= (*data++ << 8); + ins->oprs[c-040].offset |= (((unsigned) *data++) << 8); ins->oprs[c-040].offset |= (((long) *data++) << 16); ins->oprs[c-040].offset |= (((long) *data++) << 24); } if (c >= 044 && c <= 046) { ins->oprs[c-044].offset = *data++; - ins->oprs[c-044].offset |= (*data++ << 8); + ins->oprs[c-044].offset |= (((unsigned) *data++) << 8); if (asize == 32) { ins->oprs[c-044].offset |= (((long) *data++) << 16); ins->oprs[c-044].offset |= (((long) *data++) << 24); @@ -350,13 +350,13 @@ static int matches (struct itemplate *t, unsigned char *data, int asize, } if (c >= 060 && c <= 062) { ins->oprs[c-060].offset = *data++; - ins->oprs[c-060].offset |= (*data++ << 8); + ins->oprs[c-060].offset |= (((unsigned) *data++) << 8); ins->oprs[c-060].segment |= SEG_RELATIVE; ins->oprs[c-060].segment &= ~SEG_32BIT; } if (c >= 064 && c <= 066) { ins->oprs[c-064].offset = *data++; - ins->oprs[c-064].offset |= (*data++ << 8); + ins->oprs[c-064].offset |= (((unsigned) *data++) << 8); if (osize == 32) { ins->oprs[c-064].offset |= (((long) *data++) << 16); ins->oprs[c-064].offset |= (((long) *data++) << 24); @@ -372,7 +372,7 @@ static int matches (struct itemplate *t, unsigned char *data, int asize, } if (c >= 070 && c <= 072) { ins->oprs[c-070].offset = *data++; - ins->oprs[c-070].offset |= (*data++ << 8); + ins->oprs[c-070].offset |= (((unsigned) *data++) << 8); ins->oprs[c-070].offset |= (((long) *data++) << 16); ins->oprs[c-070].offset |= (((long) *data++) << 24); ins->oprs[c-070].segment |= SEG_32BIT | SEG_RELATIVE; @@ -386,11 +386,11 @@ static int matches (struct itemplate *t, unsigned char *data, int asize, } if (c >= 0130 && c <= 0132) { ins->oprs[c-0130].offset = *data++; - ins->oprs[c-0130].offset |= (*data++ << 8); + ins->oprs[c-0130].offset |= (((unsigned) *data++) << 8); } if (c >= 0140 && c <= 0142) { ins->oprs[c-0140].offset = *data++; - ins->oprs[c-0140].offset |= (*data++ << 8); + ins->oprs[c-0140].offset |= (((unsigned) *data++) << 8); ins->oprs[c-0140].offset |= (((long) *data++) << 16); ins->oprs[c-0140].offset |= (((long) *data++) << 24); } diff --git a/output/outobj.c b/output/outobj.c index 0f8fa367..14b6cd9c 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1101,7 +1101,8 @@ static void obj_out (long segto, const void *data, unsigned long type, static void obj_write_fixup (ObjRecord *orp, int bytes, int segrel, long seg, long wrt, struct Segment *segto) { - int locat, method; + unsigned locat; + int method; int base; long tidx, fidx; struct Segment *s = NULL; diff --git a/parser.c b/parser.c index aa97aa7e..b18277f8 100644 --- a/parser.c +++ b/parser.c @@ -484,7 +484,8 @@ insn *parse_line (int pass, char *buffer, insn *result, bracket = FALSE; /* placate optimisers */ } - if((result->oprs[operand].type & FAR) && !mref) + if((result->oprs[operand].type & FAR) && !mref && + result->opcode != I_JMP && result->opcode != I_CALL) { error (ERR_NONFATAL, "invalid use of FAR operand specifier"); }