Sha256: 95372e5f6539bd6ec4857c3a32a131b35f2df177612c1a7ae89ee868fa2a1b92

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

#    This file is part of Metasm, the Ruby assembly manipulation suite
#    Copyright (C) 2006-2009 Yoann GUILLOT
#
#    Licence is LGPL, see LICENCE in the top-level directory

require 'metasm/render'
require 'metasm/cpu/arm/opcodes'

module Metasm
class ARM
	class Reg
		include Renderable
		def render
			r = self.class.i_to_s[@i]
			r += '!' if updated
			if @stype == :lsl and @shift == 0
				[r]
			elsif @stype == :ror and @shift == 0
				["#{r} RRX"]
			else
				case s = @shift
				when Integer; s = Expression[s == 0 ? 32 : s]	# lsl and ror already accounted for
				when Reg; s = self.class.i_to_s[s.i]
				end
				["#{r} #{@stype.to_s.upcase} #{s}"]
			end
		end
	end

	class Memref
		include Renderable
		def render
			o = @offset
			o = Expression[o] if o.kind_of? Integer
			case @incr
			when nil;   ['[', @base, ', ', o, ']']
			when :pre;  ['[', @base, ', ', o, ']!']
			when :post; ['[', @base, '], ', o]
			end
		end
	end

	class RegList
		include Renderable
		def render
			r = ['{']
			@list.each { |l| r << l << ', ' }
			r[-1] = '}'
			r << '^' if usermoderegs
			r
		end
	end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metasm-1.0.5 metasm/cpu/arm/render.rb
metasm-1.0.4 metasm/cpu/arm/render.rb
metasm-1.0.3 metasm/cpu/arm/render.rb
metasm-1.0.2 metasm/cpu/arm/render.rb