metasm/cpu/ppc/main.rb in metasm-1.0.3 vs metasm/cpu/ppc/main.rb in metasm-1.0.4
- old
+ new
@@ -30,11 +30,11 @@
end
@s_to_i = (0..31).inject({}) { |h, i| h.update((i == 1 ? 'sp' : "r#{i}") => i) }
@i_to_s = @s_to_i.invert
Sym = @s_to_i.sort.transpose.last
- def symbolic ; Sym[@i] end
+ def symbolic(di=nil) ; Sym[@i] end
end
# special purpose reg
class SPR < Reg
@s_to_i = {'xer' => 1, 'lr' => 8, 'ctr' => 9, 'dec' => 22, 'srr0' => 26, 'srr1' => 27,
@@ -45,11 +45,11 @@
def initialize(i)
@i = i
end
Sym = @i_to_s.sort.inject({}) { |h, (k, v)| h.update k => v.to_sym }
- def symbolic ; Sym[@i] end
+ def symbolic(di=nil) ; Sym[@i] end
def render ; [self.class.i_to_s[@i] || "spr#@i"] end
end
# floating point
class FPR < Reg
@@ -63,11 +63,11 @@
Sym = @s_to_i.sort.transpose.last
end
# machine state reg
class MSR < Reg
- def symbolic ; :msr end
+ def symbolic(di=nil) ; :msr end
def render ; ['msr'] end
end
# condition reg (7 regs * 4 bits : lt, gt, eq, of)
class CR < Reg
@@ -77,26 +77,26 @@
end
@s_to_i = (0..31).inject({}) { |h, i| h.update "cr#{i}" => i }
@i_to_s = @s_to_i.invert
Sym = @s_to_i.sort.transpose.last
- def symbolic ; "cr#@i".to_sym end
+ def symbolic(di=nil) ; "cr#@i".to_sym end
end
# indirection : reg+reg or reg+16b_off
# r0 may mean 0 in some cases (stwx)
class Memref
attr_accessor :base, :offset
def initialize(base, offset)
@base, @offset = base, offset
end
- def symbolic(orig)
+ def symbolic(di=nil)
b = @base.symbolic
b = nil if b == :r0 # XXX is it true ?
o = @offset
o = o.symbolic if o.kind_of?(Reg)
- Indirection[Expression[b, :+, o].reduce, 4, orig]
+ Indirection[Expression[b, :+, o].reduce, 4, (di.address if di)]
end
include Renderable
def render
if @offset.kind_of?(Reg)