diff options
author | Victor van den Elzen <victor.vde@gmail.com> | 2010-12-29 17:13:38 +0000 |
---|---|---|
committer | Victor van den Elzen <victor.vde@gmail.com> | 2010-12-29 18:13:38 +0100 |
commit | 6dfbddb6b071625066079fdf77fa7b8482aa6da3 (patch) | |
tree | 95dd7ab0d194b4c37cda8692e18bed4292507a99 | |
parent | 47c95ceed447fff457f898bcea4facfbf9a2f710 (diff) | |
download | nasm-6dfbddb6b071625066079fdf77fa7b8482aa6da3.tar.gz |
Move implicit operand size override logic to calc_size
It is more logical, it cleans up the code and it makes implicit
operand size override prefixes come out in the same order as explicit
ones instead of after all other prefixes.
Suggested-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | assemble.c | 44 | ||||
-rw-r--r-- | test/br3058845.asm | 2 | ||||
-rw-r--r-- | test/prefix66.asm | 28 |
3 files changed, 47 insertions, 27 deletions
@@ -976,12 +976,28 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, break; case 0320: - length += (bits != 16); + { + enum prefixes pfx = ins->prefixes[PPS_OSIZE]; + if (pfx == P_O16) + break; + if (pfx != P_none) + errfunc(ERR_WARNING | ERR_PASS2, "invalid operand size prefix"); + else + ins->prefixes[PPS_OSIZE] = P_O16; break; + } case 0321: - length += (bits == 16); + { + enum prefixes pfx = ins->prefixes[PPS_OSIZE]; + if (pfx == P_O32) + break; + if (pfx != P_none) + errfunc(ERR_WARNING | ERR_PASS2, "invalid operand size prefix"); + else + ins->prefixes[PPS_OSIZE] = P_O32; break; + } case 0322: break; @@ -1636,32 +1652,8 @@ static void gencode(int32_t segment, int64_t offset, int bits, break; case 0320: - { - enum prefixes pfx = ins->prefixes[PPS_OSIZE]; - if (pfx != P_O16 && pfx != P_none) - nasm_error(ERR_WARNING, "Invalid operand size prefix"); - if (pfx != P_O16 && bits != 16) { - ins->prefixes[PPS_OSIZE] = P_O16; - *bytes = 0x66; - out(offset, segment, bytes, OUT_RAWDATA, 1, NO_SEG, NO_SEG); - offset += 1; - } - break; - } - case 0321: - { - enum prefixes pfx = ins->prefixes[PPS_OSIZE]; - if (pfx != P_O32 && pfx != P_none) - nasm_error(ERR_WARNING, "Invalid operand size prefix"); - if (pfx != P_O32 && bits == 16) { - ins->prefixes[PPS_OSIZE] = P_O32; - *bytes = 0x66; - out(offset, segment, bytes, OUT_RAWDATA, 1, NO_SEG, NO_SEG); - offset += 1; - } break; - } case 0322: case 0323: diff --git a/test/br3058845.asm b/test/br3058845.asm index b0de5607..c42f5d50 100644 --- a/test/br3058845.asm +++ b/test/br3058845.asm @@ -11,4 +11,4 @@ cmp eax, 0xFFFF_FFFF BITS 64 cmp ax, 0xFFFF -cmp eax, 0xFFFF_FFFF ; shouldn't warn, but does currently +cmp eax, 0xFFFF_FFFF diff --git a/test/prefix66.asm b/test/prefix66.asm new file mode 100644 index 00000000..4d9eb00a --- /dev/null +++ b/test/prefix66.asm @@ -0,0 +1,28 @@ +;Testname=test; Arguments=-fbin -oprefix66.bin; Files=stdout stderr prefix66.bin + +BITS 16 +cmp ax, 1 +o16 cmp ax, 1 +o32 cmp ax, 1 + +cmp eax, 1 +o16 cmp eax, 1 +o32 cmp eax, 1 + +BITS 32 +cmp ax, 1 +o16 cmp ax, 1 +o32 cmp ax, 1 + +cmp eax, 1 +o16 cmp eax, 1 +o32 cmp eax, 1 + +BITS 64 +cmp ax, 1 +o16 cmp ax, 1 +o32 cmp ax, 1 + +cmp eax, 1 +o16 cmp eax, 1 +o32 cmp eax, 1 |