metasm/cpu/sh4/main.rb in metasm-1.0.3 vs metasm/cpu/sh4/main.rb in metasm-1.0.4
- old
+ new
@@ -46,22 +46,22 @@
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..15).map { |i| "r#{i}".to_sym }
- def symbolic ; Sym[@i] end
+ def symbolic(di=nil) ; Sym[@i] end
def render ; ["r#@i"] end
end
class RBANK < Reg
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..7).map { |i| "r#{i}_bank".to_sym }
- def symbolic ; Sym[@i] end
+ def symbolic(di=nil) ; Sym[@i] end
def render ; ["r#{@i}_bank"] end
end
# floatting-point registers
@@ -69,11 +69,11 @@
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..15).map { |i| "fr#{i}".to_sym }
- def symbolic ; Sym[@i] end
+ def symbolic(di=nil) ; Sym[@i] end
def render ; ["fr#@i"] end
end
# DR registers: double-precision floating-point registers
@@ -89,11 +89,11 @@
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..7).map { |i| "dr#{i*2}".to_sym }
- def symbolic ; Sym[@i/2] end
+ def symbolic(di=nil) ; Sym[@i/2] end
def render ; ["dr#@i"] end
end
# Single-precision floating-point vector registers
@@ -105,11 +105,11 @@
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..3).map { |i| "fv#{i*4}".to_sym }
- def symbolic ; Sym[@i/4] end
+ def symbolic(di=nil) ; Sym[@i/4] end
def render ; ["fv#@i"] end
end
# Single-precision floating-point extended registers
@@ -117,11 +117,11 @@
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..15).map { |i| "xf#{i}".to_sym }
- def symbolic ; Sym[@i] end
+ def symbolic(di=nil) ; Sym[@i] end
def render ; ["xf#@i"] end
end
# XD registers: single-precision floating-point vector registers
@@ -137,112 +137,112 @@
attr_accessor :i
def initialize(i); @i = i end
Sym = (0..7).map { |i| "xd#{i*2}".to_sym }
- def symbolic ; Sym[@i/2] end
+ def symbolic(di=nil) ; Sym[@i/2] end
def render ; ["xd#@i"] end
end
# Single-precision floating-point extended register matrix
class XMTRX < Reg
- def symbolic ; :xmtrx ; end
+ def symbolic(di=nil) ; :xmtrx ; end
def render ; ['xmtrx'] ; end
end
# Multiply-and-accumulate register high
class MACH < Reg
- def symbolic ; :mach end
+ def symbolic(di=nil) ; :mach end
def render ; ['mach'] end
end
# Multiply-and-accumulate register low
class MACL < Reg
- def symbolic ; :macl end
+ def symbolic(di=nil) ; :macl end
def render ; ['macl'] end
end
# Procedure register
class PR < Reg
- def symbolic ; :pr end
+ def symbolic(di=nil) ; :pr end
def render ; ['pr'] end
end
# Floating-point communication register
class FPUL < Reg
- def symbolic ; :fpul end
+ def symbolic(di=nil) ; :fpul end
def render ; ['fpul'] end
end
# Program counter
class PC < Reg
- def symbolic ; :pc end
+ def symbolic(di=nil) ; :pc end
def render ; ['pc'] end
end
# Floating-point status/control register
class FPSCR < Reg
- def symbolic ; :fpscr end
+ def symbolic(di=nil) ; :fpscr end
def render ; ['fpscr'] end
end
#----------------------- Control registers -----------------------------
# Status register
class SR < Reg
- def symbolic ; :sr end
+ def symbolic(di=nil) ; :sr end
def render ; ['sr'] end
end
# Saved status register
class SSR < Reg
- def symbolic ; :ssr end
+ def symbolic(di=nil) ; :ssr end
def render ; ['ssr'] end
end
# Saved program counter
class SPC < Reg
- def symbolic ; :spc end
+ def symbolic(di=nil) ; :spc end
def render ; ['spc'] end
end
# Global base register
class GBR < Reg
- def symbolic ; :spc end
+ def symbolic(di=nil) ; :spc end
def render ; ['gbr'] end
end
# Vector base register
class VBR < Reg
- def symbolic ; :spc end
+ def symbolic(di=nil) ; :spc end
def render ; ['vbr'] end
end
# Saved general register
class SGR < Reg
- def symbolic ; :sgr end
+ def symbolic(di=nil) ; :sgr end
def render ; ['sgr'] end
end
# Debug base register
class DBR < Reg
- def symbolic ; :dbr end
+ def symbolic(di=nil) ; :dbr end
def render ; ['dbr'] end
end
class Memref
# action: pre/post (inc/dec)rement
@@ -251,11 +251,13 @@
def initialize(base, offset, action = nil)
base = Expression[base] if base.kind_of? Integer
@base, @disp, @action = base, offset, action
end
- def symbolic(orig=nil, sz=32)
+ def symbolic(di=nil)
+ sz = 32
+ sz = di.opcode.props[:memsz] if di
b = @base
b = b.symbolic if b.kind_of? Reg
b = Expression[b, :-, sz/8] if @action == :pre
@@ -265,10 +267,10 @@
e = Expression[b, :+, o].reduce
else
e = Expression[b].reduce
end
- Indirection[e, sz, orig]
+ Indirection[e, sz, (di.address if di)]
end
include Renderable
def render