From 5d62e57a0c8fd4b2aa9c9b671ba43be2817d789f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 19 Aug 2010 17:04:36 -0700 Subject: [PATCH] ndisasm: handle VEX.LIG A lot of instructions ignore the L bit in the VEX prefix, just like a lot of instructions ignore the W bit, so don't use them in the sub-table select. Signed-off-by: H. Peter Anvin --- disasm.c | 2 +- insns.h | 2 +- insns.pl | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/disasm.c b/disasm.c index 81282e61..ba282d34 100644 --- a/disasm.c +++ b/disasm.c @@ -1081,7 +1081,7 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize, prefix.vex_lp = prefix.vex[1] & 7; } - ix = itable_vex[RV_VEX][prefix.vex_m][prefix.vex_lp]; + ix = itable_vex[RV_VEX][prefix.vex_m][prefix.vex_lp & 3]; } end_prefix = true; break; diff --git a/insns.h b/insns.h index 4ae2499c..4f3dd80b 100644 --- a/insns.h +++ b/insns.h @@ -32,7 +32,7 @@ struct disasm_index { /* Tables for the assembler and disassembler, respectively */ extern const struct itemplate * const nasm_instructions[]; extern const struct disasm_index itable[256]; -extern const struct disasm_index * const itable_vex[2][32][8]; +extern const struct disasm_index * const itable_vex[2][32][4]; /* Common table for the byte codes */ extern const uint8_t nasm_bytecodes[]; diff --git a/insns.pl b/insns.pl index 3313a6c2..adc1814b 100755 --- a/insns.pl +++ b/insns.pl @@ -52,8 +52,8 @@ $vex_classes = scalar(@vex_class); for ($c = 0; $c < $vex_classes; $c++) { $vexmap{$vex_class[$c]} = $c; for ($m = 0; $m < 32; $m++) { - for ($lp = 0; $lp < 8; $lp++) { - push(@vexlist, sprintf("%s%02X%01X", $vex_class[$c], $m, $lp)); + for ($p = 0; $p < 4; $p++) { + push(@vexlist, sprintf("%s%02X%01X", $vex_class[$c], $m, $p)); } } } @@ -319,15 +319,15 @@ if ( !defined($output) || $output eq 'd' ) { print D "};\n"; } - printf D "\nconst struct disasm_index * const itable_vex[%d][32][8] =\n", + printf D "\nconst struct disasm_index * const itable_vex[%d][32][4] =\n", $vex_classes; print D "{\n"; for ($c = 0; $c < $vex_classes; $c++) { print D " {\n"; for ($m = 0; $m < 32; $m++) { print D " {\n"; - for ($lp = 0; $lp < 8; $lp++) { - $vp = sprintf("%s%02X%01X", $vex_class[$c], $m, $lp); + for ($p = 0; $p < 4; $p++) { + $vp = sprintf("%s%02X%01X", $vex_class[$c], $m, $p); if ($is_prefix{$vp}) { printf D " itable_%s,\n", $vp; } else { @@ -628,7 +628,7 @@ sub startseq($$) { $wlp = shift(@codes); $c = ($m >> 6); $m = $m & 31; - $prefix .= sprintf('%s%02X%01X', $vex_class[$c], $m, $wlp & 7); + $prefix .= sprintf('%s%02X%01X', $vex_class[$c], $m, $wlp & 3); } elsif ($c0 >= 0172 && $c0 <= 174) { shift(@codes); # Skip is4 control byte } else { -- 2.11.4.GIT