Sha256: a34a2451663cc62e4b2d3fb7dda83e36f503ba4142ec063e85f5e8f314c346ab

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 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/main'

module Metasm
class CY16 < CPU
	class Reg
		class << self
			attr_accessor :s_to_i, :i_to_s
		end
		@i_to_s = (0..14).inject({}) { |h, i| h.update i => "r#{i}" }
		@i_to_s[15] = 'sp'
		@s_to_i = @i_to_s.invert

		attr_accessor :i
		def initialize(i)
			@i = i
		end

		def symbolic(orig=nil) ; to_s.to_sym ; end

		def self.from_str(s)
			raise "Bad name #{s.inspect}" if not x = @s_to_i[s]
			new(x)
		end
	end

	class Memref
		attr_accessor :base, :offset, :sz, :autoincr
		def initialize(base, offset, sz=nil, autoincr=nil)
			@base = base
			offset = Expression[offset] if offset
			@offset = offset
			@sz = sz
			@autoincr = autoincr
		end

		def symbolic(orig)
			p = nil
			p = Expression[p, :+, @base.symbolic] if base
			p = Expression[p, :+, @offset] if offset
			Indirection[p.reduce, @sz, orig]
		end
	end

	def initialize(family = :latest)
		super()
		@endianness = :little
		@size = 16
		@family = family
	end

	def init_opcode_list
		send("init_#@family")
		@opcode_list
	end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metasm-1.0.3 metasm/cpu/cy16/main.rb
metasm-1.0.2 metasm/cpu/cy16/main.rb