summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorBen Rudiak-Gould <benrudiak@gmail.com>2013-03-01 10:28:32 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2013-03-01 10:28:32 +0400
commit4e8396b5cf3981f0746ed815ce8b6fb89146821e (patch)
treea97cc2910461cab626c554e09729ea44ba07f747 /parser.c
parent57162eb084ee80c2f024663c1bfc10c82bb83b20 (diff)
downloadnasm-4e8396b5cf3981f0746ed815ce8b6fb89146821e.tar.gz
nasm-4e8396b5cf3981f0746ed815ce8b6fb89146821e.tar.bz2
nasm-4e8396b5cf3981f0746ed815ce8b6fb89146821e.zip
Remove +s
It doesn't seem worth >200 lines of C and Perl to save ~50 lines in insns.dat. In order to make this work I had to rename sbyte16/sbyte32 so that they can take an ordinary size suffix (their size suffix was formerly treated specially). This fixes one disassembly bug: 48C7C000000080 disassembles to mov rax,0x80000000, which reassembles to B800000080, which loads a different value. Signed-off-by: Ben Rudiak-Gould <benrudiak@gmail.com> Acked-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/parser.c b/parser.c
index 889adf3..99bbc25 100644
--- a/parser.c
+++ b/parser.c
@@ -853,7 +853,7 @@ is_expression:
if(optimizing >= 0 && !(result->oprs[operand].type & STRICT)) {
/* Be optimistic */
result->oprs[operand].type |=
- SBYTE16 | SBYTE32 | SBYTE64 | UDWORD64 | SDWORD64;
+ UNITY | SBYTEWORD | SBYTEDWORD | UDWORD | SDWORD;
}
} else if (is_reloc(value)) { /* it's immediate */
result->oprs[operand].type |= IMMEDIATE;
@@ -862,25 +862,19 @@ is_expression:
result->oprs[operand].wrt = reloc_wrt(value);
if (is_simple(value)) {
- if (reloc_value(value) == 1)
+ uint64_t n = reloc_value(value);
+ if (n == 1)
result->oprs[operand].type |= UNITY;
if (optimizing >= 0 &&
!(result->oprs[operand].type & STRICT)) {
- int64_t v64 = reloc_value(value);
- int32_t v32 = (int32_t)v64;
- int16_t v16 = (int16_t)v32;
-
- if (v64 >= -128 && v64 <= 127)
- result->oprs[operand].type |= SBYTE64;
- if (v32 >= -128 && v32 <= 127)
- result->oprs[operand].type |= SBYTE32;
- if (v16 >= -128 && v16 <= 127)
- result->oprs[operand].type |= SBYTE16;
- if ((uint64_t)v64 <= UINT64_C(0xffffffff))
- result->oprs[operand].type |= UDWORD64;
- if (v64 >= -INT64_C(0x80000000) &&
- v64 <= INT64_C(0x7fffffff))
- result->oprs[operand].type |= SDWORD64;
+ if ((uint32_t) (n + 128) <= 255)
+ result->oprs[operand].type |= SBYTEDWORD;
+ if ((uint16_t) (n + 128) <= 255)
+ result->oprs[operand].type |= SBYTEWORD;
+ if (n <= 0xFFFFFFFF)
+ result->oprs[operand].type |= UDWORD;
+ if (n + 0x80000000 <= 0xFFFFFFFF)
+ result->oprs[operand].type |= SDWORD;
}
}
} else { /* it's a register */