metasm 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -194,6 +194,7 @@ class Ia32
194
194
  when :reg; Reg.new field_val[a], opsz
195
195
  when :eeec; CtrlReg.new field_val[a]
196
196
  when :eeed; DbgReg.new field_val[a]
197
+ when :eeet; TstReg.new field_val[a]
197
198
  when :seg2, :seg2A, :seg3, :seg3A; SegReg.new field_val[a]
198
199
  when :regfp; FpReg.new field_val[a]
199
200
  when :regmmx; SimdReg.new field_val[a], mmxsz
@@ -290,7 +290,7 @@ class Ia32
290
290
  # mov cr0 etc
291
291
  a1, a2 = di.instruction.args
292
292
  case a1
293
- when Ia32::CtrlReg, Ia32::DbgReg, Ia32::SegReg
293
+ when Ia32::CtrlReg, Ia32::DbgReg, Ia32::TstReg, Ia32::SegReg
294
294
  sz = a1.kind_of?(Ia32::SegReg) ? 16 : 32
295
295
  if not dcmp.c_parser.toplevel.symbol["intrinsic_set_#{a1}"]
296
296
  dcmp.c_parser.parse("void intrinsic_set_#{a1}(__int#{sz});")
@@ -302,7 +302,7 @@ class Ia32
302
302
  next
303
303
  end
304
304
  case a2
305
- when Ia32::CtrlReg, Ia32::DbgReg, Ia32::SegReg
305
+ when Ia32::CtrlReg, Ia32::DbgReg, Ia32::TstReg, Ia32::SegReg
306
306
  if not dcmp.c_parser.toplevel.symbol["intrinsic_get_#{a2}"]
307
307
  sz = a2.kind_of?(Ia32::SegReg) ? 16 : 32
308
308
  dcmp.c_parser.parse("__int#{sz} intrinsic_get_#{a2}(void);")
@@ -240,7 +240,7 @@ class Ia32
240
240
  postponed = []
241
241
  oi.each { |oa, ia|
242
242
  case oa
243
- when :reg, :seg3, :seg3A, :seg2, :seg2A, :eeec, :eeed, :regfp, :regmmx, :regxmm
243
+ when :reg, :seg3, :seg3A, :seg2, :seg2A, :eeec, :eeed, :eeet, :regfp, :regmmx, :regxmm
244
244
  # field arg
245
245
  set_field[oa, ia.val]
246
246
  pfx << 0x66 if oa == :regmmx and op.props[:xmmx] and ia.sz == 128
@@ -78,6 +78,11 @@ class Ia32 < CPU
78
78
  simple_map((0..7).map { |i| [i, "cr#{i}"] })
79
79
  end
80
80
 
81
+ # test registers (tr0..tr7) (undocumented)
82
+ class TstReg < Argument
83
+ simple_map((0..7).map { |i| [i, "tr#{i}"] })
84
+ end
85
+
81
86
  # floating point registers
82
87
  class FpReg < Argument
83
88
  simple_map((0..7).map { |i| [i, "ST(#{i})"] } << [nil, 'ST'])
@@ -11,14 +11,14 @@ class Ia32
11
11
  def init_cpu_constants
12
12
  @opcode_list ||= []
13
13
  @fields_mask.update :w => 1, :s => 1, :d => 1, :modrm => 0xc7,
14
- :reg => 7, :eeec => 7, :eeed => 7, :seg2 => 3, :seg3 => 7,
14
+ :reg => 7, :eeec => 7, :eeed => 7, :eeet => 7, :seg2 => 3, :seg3 => 7,
15
15
  :regfp => 7, :regmmx => 7, :regxmm => 7
16
16
  @fields_mask[:seg2A] = @fields_mask[:seg2]
17
17
  @fields_mask[:seg3A] = @fields_mask[:seg3]
18
18
  @fields_mask[:modrmA] = @fields_mask[:modrm]
19
19
 
20
20
  @valid_args.concat [:i, :i8, :u8, :u16, :reg, :seg2, :seg2A,
21
- :seg3, :seg3A, :eeec, :eeed, :modrm, :modrmA, :mrm_imm,
21
+ :seg3, :seg3A, :eeec, :eeed, :eeet, :modrm, :modrmA, :mrm_imm,
22
22
  :farptr, :imm_val1, :imm_val3, :reg_cl, :reg_eax,
23
23
  :reg_dx, :regfp, :regfp0, :modrmmmx, :regmmx,
24
24
  :modrmxmm, :regxmm] - @valid_args
@@ -177,6 +177,7 @@ class Ia32
177
177
  addop 'ltr', [0x0F, 0x00], 3
178
178
  addop('mov', [0x0F, 0x20, 0xC0], :reg, {:d => [1, 1], :eeec => [2, 3]}, :eeec) { |op| op.args.reverse! }
179
179
  addop('mov', [0x0F, 0x21, 0xC0], :reg, {:d => [1, 1], :eeed => [2, 3]}, :eeed) { |op| op.args.reverse! }
180
+ addop('mov', [0x0F, 0x24, 0xC0], :reg, {:d => [1, 1], :eeet => [2, 3]}, :eeet) { |op| op.args.reverse! }
180
181
  addop('mov', [0x8C], 0, {:d => [0, 1], :seg3 => [1, 3]}, :seg3) { |op| op.args.reverse! }
181
182
  addop 'out', [0xE6], nil, {:w => [0, 0]}, :u8, :reg_eax
182
183
  addop 'out', [0xE6], nil, {:w => [0, 0]}, :reg_eax, :u8
@@ -167,7 +167,7 @@ end
167
167
  end
168
168
 
169
169
  def parse_argregclasslist
170
- [Reg, SimdReg, SegReg, DbgReg, CtrlReg, FpReg]
170
+ [Reg, SimdReg, SegReg, DbgReg, TstReg, CtrlReg, FpReg]
171
171
  end
172
172
  def parse_modrm(lex, tok, cpu)
173
173
  ModRM.parse(lex, tok, cpu)
@@ -267,6 +267,7 @@ end
267
267
  when :seg2A; arg.kind_of? SegReg and arg.val < 4 and arg.val != 1
268
268
  when :eeec; arg.kind_of? CtrlReg
269
269
  when :eeed; arg.kind_of? DbgReg
270
+ when :eeet; arg.kind_of? TstReg
270
271
  when :modrmA; arg.kind_of? ModRM
271
272
  when :mrm_imm; arg.kind_of? ModRM and not arg.s and not arg.i and not arg.b
272
273
  when :farptr; arg.kind_of? Farptr
@@ -14,7 +14,7 @@ class Ia32
14
14
  include Renderable
15
15
  end
16
16
 
17
- [SegReg, DbgReg, CtrlReg, FpReg].each { |c| c.class_eval {
17
+ [SegReg, DbgReg, TstReg, CtrlReg, FpReg].each { |c| c.class_eval {
18
18
  def render ; [self.class.i_to_s[@val]] end
19
19
  } }
20
20
  [Reg, SimdReg].each { |c| c.class_eval {
@@ -112,6 +112,7 @@ class X86_64
112
112
  when :reg; Reg.new field_val_r[a], opsz
113
113
  when :eeec; CtrlReg.new field_val_r[a]
114
114
  when :eeed; DbgReg.new field_val_r[a]
115
+ when :eeet; TstReg.new field_val_r[a]
115
116
  when :seg2, :seg2A, :seg3, :seg3A; SegReg.new field_val[a]
116
117
  when :regmmx; SimdReg.new field_val_r[a], mmxsz
117
118
  when :regxmm; SimdReg.new field_val_r[a], 128
@@ -172,7 +172,7 @@ class X86_64
172
172
  else
173
173
  rex_b = ia.val_rex
174
174
  end
175
- when :seg3, :seg3A, :seg2, :seg2A, :eeec, :eeed, :regfp, :regxmm, :regmmx
175
+ when :seg3, :seg3A, :seg2, :seg2A, :eeec, :eeed, :eeet, :regfp, :regxmm, :regmmx
176
176
  set_field[oa, ia.val & 7]
177
177
  rex_r = 1 if ia.val > 7
178
178
  pfx << 0x66 if oa == :regmmx and op.props[:xmmx] and ia.sz == 128
@@ -94,6 +94,10 @@ class X86_64 < Ia32
94
94
  simple_map((0..15).map { |i| [i, "cr#{i}"] })
95
95
  end
96
96
 
97
+ class TstReg < Ia32::TstReg
98
+ simple_map((0..15).map { |i| [i, "tr#{i}"] })
99
+ end
100
+
97
101
  # Create a new instance of an X86 cpu
98
102
  # arguments (any order)
99
103
  # - instruction set (386, 486, sse2...) [latest]
@@ -29,7 +29,7 @@ class X86_64
29
29
 
30
30
  # needed due to how ruby inheritance works wrt constants
31
31
  def parse_argregclasslist
32
- [Reg, SimdReg, SegReg, DbgReg, CtrlReg, FpReg]
32
+ [Reg, SimdReg, SegReg, DbgReg, TstReg, CtrlReg, FpReg]
33
33
  end
34
34
  # same inheritance sh*t
35
35
  def parse_modrm(lex, tok, cpu)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yoann Guillot
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-26 00:00:00 Z
18
+ date: 2011-04-30 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Metasm is a cross-architecture assembler, disassembler, compiler, linker and debugger in pure Ruby with no dependencies.