summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2012-12-04 02:33:41 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2012-12-04 02:33:41 +0400
commitb06c14507830ef3edeaf32b2b0be7a0c430702e3 (patch)
tree9af1a394814708ffd2effd176a42f1e1d9a5c60a
parentdfcc3d3900339df3dc59a5d44a143ad77a0166de (diff)
downloadnasm-phi.tar.gz
insns.pl: Various style polyshingphi
- convert tabs to spaces - align octal opcodes No func changes. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rwxr-xr-xinsns.pl162
1 files changed, 82 insertions, 80 deletions
diff --git a/insns.pl b/insns.pl
index b154dbd7..0e42b5e7 100755
--- a/insns.pl
+++ b/insns.pl
@@ -528,19 +528,19 @@ sub decodify($$) {
my @codes = ();
unless ($codestr eq 'ignore') {
- while ($c ne '') {
- if ($c =~ /^\\x([0-9a-f]+)(.*)$/i) {
- push(@codes, hex $1);
- $c = $2;
- next;
- } elsif ($c =~ /^\\([0-7]{1,3})(.*)$/) {
- push(@codes, oct $1);
- $c = $2;
- next;
- } else {
- die "$fname: unknown code format in \"$codestr\"\n";
- }
- }
+ while ($c ne '') {
+ if ($c =~ /^\\x([0-9a-f]+)(.*)$/i) {
+ push(@codes, hex $1);
+ $c = $2;
+ next;
+ } elsif ($c =~ /^\\([0-7]{1,3})(.*)$/) {
+ push(@codes, oct $1);
+ $c = $2;
+ next;
+ } else {
+ die "$fname: unknown code format in \"$codestr\"\n";
+ }
+ }
}
return @codes;
@@ -670,73 +670,75 @@ sub byte_code_compile($$) {
my $opex;
my %imm_codes = (
- 'ib,s' => 014, # Signed imm8
- 'ib' => 020, # imm8
- 'ib,u' => 024, # Unsigned imm8
- 'iw' => 030, # imm16
- 'ibx' => 0274, # imm8 sign-extended to opsize
- 'iwd' => 034, # imm16 or imm32, depending on opsize
- 'id' => 040, # imm32
- 'idx' => 0254, # imm32 extended to 64 bits
- 'iwdq' => 044, # imm16/32/64, depending on opsize
- 'rel8' => 050,
- 'iq' => 054,
- 'rel16' => 060,
- 'rel' => 064, # 16 or 32 bit relative operand
- 'rel32' => 070,
- 'seg' => 074,
- 'ibw' => 0140, # imm16 that can be bytified
- 'ibd' => 0150, # imm32 that can be bytified
- 'ibd,s' => 0250 # imm32 that can be bytified, sign extended to 64 bits
+ 'ib,s' => 014, # Signed imm8
+ 'ib' => 020, # imm8
+ 'ib,u' => 024, # Unsigned imm8
+ 'iw' => 030, # imm16
+ 'ibx' => 0274, # imm8 sign-extended to opsize
+ 'iwd' => 034, # imm16 or imm32, depending on opsize
+ 'id' => 040, # imm32
+ 'idx' => 0254, # imm32 extended to 64 bits
+ 'iwdq' => 044, # imm16/32/64, depending on opsize
+ 'rel8' => 050,
+ 'iq' => 054,
+ 'rel16' => 060,
+ 'rel' => 064, # 16 or 32 bit relative operand
+ 'rel32' => 070,
+ 'seg' => 074,
+ 'ibw' => 0140, # imm16 that can be bytified
+ 'ibd' => 0150, # imm32 that can be bytified
+ 'ibd,s' => 0250 # imm32 that can be bytified, sign extended to 64 bits
);
my %imm_codes_bytifiers = (
- 'ibw' => 0144,
- 'ibd' => 0154,
- 'ibd,s' => 0154
+ 'ibw' => 0144,
+ 'ibd' => 0154,
+ 'ibd,s' => 0154
);
my %plain_codes = (
- 'o16' => 0320, # 16-bit operand size
- 'o32' => 0321, # 32-bit operand size
- 'odf' => 0322, # Operand size is default
- 'o64' => 0324, # 64-bit operand size requiring REX.W
- 'o64nw' => 0323, # Implied 64-bit operand size (no REX.W)
- 'a16' => 0310,
- 'a32' => 0311,
- 'adf' => 0312, # Address size is default
- 'a64' => 0313,
- '!osp' => 0364,
- '!asp' => 0365,
- 'f2i' => 0332, # F2 prefix, but 66 for operand size is OK
- 'f3i' => 0333, # F3 prefix, but 66 for operand size is OK
- 'pushseg' => 0344,
- 'popseg' => 0345,
- 'pushseg2' => 0346,
- 'popseg2' => 0347,
- 'mustrep' => 0336,
- 'mustrepne' => 0337,
- 'rex.l' => 0334,
- 'norexb' => 0314,
- 'norexx' => 0315,
- 'norexr' => 0316,
- 'norexw' => 0317,
- 'repe' => 0335,
- 'nohi' => 0325, # Use spl/bpl/sil/dil even without REX
- 'wait' => 0341, # Needs a wait prefix
- 'resb' => 0340,
- 'jcc8' => 0370, # Match only if Jcc possible with single byte
- 'jmp8' => 0371, # Match only if JMP possible with single byte
- 'jlen' => 0373, # Length of jump
- 'hlexr' => 0271,
- 'hlenl' => 0272,
- 'hle' => 0273,
- # This instruction takes XMM VSIB
- 'vsibx' => 0374,
- 'vm32x' => 0374,
- 'vm64x' => 0374,
- # This instruction takes YMM VSIB
- 'vsiby' => 0375,
- 'vm32y' => 0375,
- 'vm64y' => 0375
+ 'o16' => 0320, # 16-bit operand size
+ 'o32' => 0321, # 32-bit operand size
+ 'odf' => 0322, # Operand size is default
+ 'o64' => 0324, # 64-bit operand size requiring REX.W
+ 'o64nw' => 0323, # Implied 64-bit operand size (no REX.W)
+ 'a16' => 0310,
+ 'a32' => 0311,
+ 'adf' => 0312, # Address size is default
+ 'a64' => 0313,
+ '!osp' => 0364,
+ '!asp' => 0365,
+ 'f2i' => 0332, # F2 prefix, but 66 for operand size is OK
+ 'f3i' => 0333, # F3 prefix, but 66 for operand size is OK
+ 'pushseg' => 0344,
+ 'popseg' => 0345,
+ 'pushseg2' => 0346,
+ 'popseg2' => 0347,
+ 'mustrep' => 0336,
+ 'mustrepne' => 0337,
+ 'rex.l' => 0334,
+ 'norexb' => 0314,
+ 'norexx' => 0315,
+ 'norexr' => 0316,
+ 'norexw' => 0317,
+ 'repe' => 0335,
+ 'nohi' => 0325, # Use spl/bpl/sil/dil even without REX
+ 'wait' => 0341, # Needs a wait prefix
+ 'resb' => 0340,
+ 'jcc8' => 0370, # Match only if Jcc possible with single byte
+ 'jmp8' => 0371, # Match only if JMP possible with single byte
+ 'jlen' => 0373, # Length of jump
+ 'hlexr' => 0271,
+ 'hlenl' => 0272,
+ 'hle' => 0273,
+
+ # This instruction takes XMM VSIB
+ 'vsibx' => 0374,
+ 'vm32x' => 0374,
+ 'vm64x' => 0374,
+
+ # This instruction takes YMM VSIB
+ 'vsiby' => 0375,
+ 'vm32y' => 0375,
+ 'vm64y' => 0375
);
unless ($str =~ /^(([^\s:]*)\:|)\s*(.*\S)\s*$/) {
@@ -762,11 +764,11 @@ sub byte_code_compile($$) {
my $last_imm = 'h';
my $prefix_ok = 1;
foreach $op (split(/\s*(?:\s|(?=[\/\\]))/, $opc)) {
- my $pc = $plain_codes{$op};
+ my $pc = $plain_codes{$op};
- if (defined $pc) {
- # Plain code
- push(@codes, $pc);
+ if (defined $pc) {
+ # Plain code
+ push(@codes, $pc);
} elsif ($prefix_ok && $op =~ /^(66|f2|f3|np)$/) {
# 66/F2/F3 prefix used as an opcode extension, or np = no prefix
if ($op eq '66') {