Sha256: 387b02f051ee7c9d1b98029949285ae938bbe248916037a678a2e31af1e64732

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

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/mips/opcodes'
require 'metasm/render'

module Metasm
class MIPS
	class Reg
		include Renderable
		def render ; [self.class.i_to_s[@i]] end
	end
	class FpReg
		include Renderable
		def render ; [self.class.i_to_s[@i]] end
	end
	class Memref
		include Renderable
		def render ; [@offset, '(', @base, ')'] end
	end

	def render_instruction(i)
		r = []
		r << i.opname
		if not i.args.empty?
			r << ' '
			if (a = i.args.first).kind_of? Expression and a.op == :- and a.lexpr.kind_of? String and a.rexpr.kind_of? String and opcode_list_byname[i.opname].first.props[:setip]
				# jmp foo is stored as jmp foo - bar ; bar:
				r << a.lexpr
			else
				i.args.each { |a_|
					r << a_ << ', '
				}
				r.pop
			end
		end
		r
	end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metasm-1.0.1 lib/metasm/mips/render.rb
metasm-1.0.0 lib/metasm/mips/render.rb