Remove is_sbyte64() and replace with is_sbyte32() plus custom warning

is_sbyte64() was equivalent to is_sbyte32() plus the warning; however,
the warning is only used in one place (and conflicts with another
warning there), so remove the function.

Furthermore, add back the test for pure immediates in
possible_sbyte(); they had been broken out but never folded back in --
and are essential.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2008-10-07 09:56:38 -07:00
parent 98a22a65c0
commit ad6b8595b9

View File

@ -746,7 +746,8 @@ int64_t insn_size(int32_t segment, int64_t offset, int bits, uint32_t cp,
static bool possible_sbyte(operand *o)
{
return !(o->opflags & OPFLAG_FORWARD) &&
return o->wrt == NO_SEG && o->segment == NO_SEG &&
!(o->opflags & OPFLAG_FORWARD) &&
optimizing >= 0 && !(o->type & STRICT);
}
@ -773,30 +774,6 @@ static bool is_sbyte32(operand *o)
return v >= -128 && v <= 127;
}
/* check that opn[op] is a signed byte of size 32; warn if this is not
the original value when extended to 64 bits */
static bool is_sbyte64(operand *o, bool warn)
{
int64_t v64;
int32_t v;
if (!(o->wrt == NO_SEG && o->segment == NO_SEG))
return false; /* Not a pure immediate */
v64 = o->offset;
v = (int32_t)v64;
if (warn && v64 != v)
errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV,
"signed dword immediate exceeds bounds");
/* dead in the water on forward reference or External */
if (!possible_sbyte(o))
return false;
v = o->offset;
return v >= -128 && v <= 127;
}
static int64_t calcsize(int32_t segment, int64_t offset, int bits,
insn * ins, const uint8_t *codes)
{
@ -974,7 +951,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits,
case 0251:
case 0252:
case 0253:
length += is_sbyte64(opx, false) ? 1 : 4;
length += is_sbyte32(opx) ? 1 : 4;
break;
case 0260:
case 0261:
@ -1598,8 +1575,12 @@ static void gencode(int32_t segment, int64_t offset, int bits,
case 0252:
case 0253:
data = opx->offset;
warn_overflow(4, opx);
if (is_sbyte64(opx, true)) {
if (opx->wrt == NO_SEG && opx->segment == NO_SEG &&
(int32_t)data != (int64_t)data) {
errfunc(ERR_WARNING | ERR_PASS2 | ERR_WARN_NOV,
"signed dword immediate exceeds bounds");
}
if (is_sbyte32(opx)) {
bytes[0] = data;
out(offset, segment, bytes, OUT_RAWDATA, 1, NO_SEG,
NO_SEG);