aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-14 15:23:00 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-14 15:23:00 -0700
commit02b60ddd1c86ba6d932301f4ab205027beafc688 (patch)
tree7b08d541a383f931ef740c2be512e820c95f070a
parenta6358096202e1b3bec58decabaad007f4957392c (diff)
downloadnasm-02b60ddd1c86ba6d932301f4ab205027beafc688.tar.gz
nasm-02b60ddd1c86ba6d932301f4ab205027beafc688.tar.xz
nasm-02b60ddd1c86ba6d932301f4ab205027beafc688.zip
LEA: allow immediate syntax; ignore operand size entirely
The memory operand size of LEA doesn't matter in any way as it isn't "real memory". Add an ANYSIZE option to ignore sizes entirely. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--asm/assemble.c3
-rw-r--r--include/iflag.h2
-rw-r--r--x86/iflags.ph1
-rw-r--r--x86/insns.dat9
4 files changed, 11 insertions, 4 deletions
diff --git a/asm/assemble.c b/asm/assemble.c
index aa00eb8b..e24ebdb5 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -2440,6 +2440,9 @@ static enum match_result matches(const struct itemplate *itemp,
case IF_GENBIT(IF_SZ):
asize = BITS512;
break;
+ case IF_GENBIT(IF_ANYSIZE):
+ asize = SIZE_MASK;
+ break;
case IF_GENBIT(IF_SIZE):
switch (bits) {
case 16:
diff --git a/include/iflag.h b/include/iflag.h
index 7cf38eaa..a268c9bb 100644
--- a/include/iflag.h
+++ b/include/iflag.h
@@ -71,7 +71,7 @@ static inline int iflag_cmp(const iflag_t *a, const iflag_t *b)
IF_GEN_HELPER(xor, ^)
/* Some helpers which are to work with predefined masks */
-#define IF_SMASK (IFM_SB|IFM_SW|IFM_SD|IFM_SQ|IFM_SO|IFM_SY|IFM_SZ|IFM_SIZE)
+#define IF_SMASK (IFM_SB|IFM_SW|IFM_SD|IFM_SQ|IFM_SO|IFM_SY|IFM_SZ|IFM_SIZE|IFM_ANYSIZE)
#define IF_ARMASK (IFM_AR0|IFM_AR1|IFM_AR2|IFM_AR3|IFM_AR4)
#define _itemp_smask(idx) (insns_flags[(idx)].field[0] & IF_SMASK)
diff --git a/x86/iflags.ph b/x86/iflags.ph
index 723855c0..8f0a80fd 100644
--- a/x86/iflags.ph
+++ b/x86/iflags.ph
@@ -16,6 +16,7 @@ if_("SY", "Unsized operands can't be non-yword");
if_("SZ", "Unsized operands can't be non-zword");
if_("SIZE", "Unsized operands must match the bitsize");
if_("SX", "Unsized operands not allowed");
+if_("ANYSIZE", "Ignore operand size even if explicit");
if_("AR0", "SB, SW, SD applies to argument 0");
if_("AR1", "SB, SW, SD applies to argument 1");
if_("AR2", "SB, SW, SD applies to argument 2");
diff --git a/x86/insns.dat b/x86/insns.dat
index a35c807b..0f18e826 100644
--- a/x86/insns.dat
+++ b/x86/insns.dat
@@ -732,9 +732,12 @@ LAR reg64,reg32 [rm: o64 0f 02 /r] X64,PROT
LAR reg64,reg64 [rm: o64 0f 02 /r] X64,PROT
LDS reg16,mem [rm: o16 c5 /r] 8086,NOLONG
LDS reg32,mem [rm: o32 c5 /r] 386,NOLONG
-LEA reg16,mem [rm: o16 8d /r] 8086
-LEA reg32,mem [rm: o32 8d /r] 386
-LEA reg64,mem [rm: o64 8d /r] X64
+LEA reg16,mem [rm: o16 8d /r] 8086,ANYSIZE
+LEA reg32,mem [rm: o32 8d /r] 386,ANYSIZE
+LEA reg64,mem [rm: o64 8d /r] X64,ANYSIZE
+LEA reg16,imm [rm: o16 8d /r] 8086,ND,ANYSIZE
+LEA reg32,imm [rm: o32 8d /r] 386,ND,ANYSIZE
+LEA reg64,imm [rm: o64 8d /r] X64,ND,ANYSIZE
LEAVE void [ c9] 186
LES reg16,mem [rm: o16 c4 /r] 8086,NOLONG
LES reg32,mem [rm: o32 c4 /r] 386,NOLONG