node/lib/metasm/metasm/cpu/x86_64/compile_c.rb
def make_volatile(e, type, rsz=@cpusz)
		if e.kind_of? ModRM or @state.bound.index(e)
			if type.integral? or type.pointer?
				oldval = @state.cache[e]
				unuse e
				sz = typesize[type.pointer? ? :ptr : type.name]*8
				if sz < @cpusz or sz < rsz or e.sz < rsz
					e2 = inuse findreg(rsz)
					op = ((type.specifier == :unsigned) ? 'movzx' : 'movsx')
					op = 'mov' if e.sz == e2.sz
					if e2.sz == 64 and e.sz == 32
						if op == 'movsx'
							instr 'movsxd', e2, e
						else
							instr 'mov', Reg.new(e2.val, 32), e
						end
					else
						instr op, e2, e
					end
				else
					e2 = inuse findreg(sz)
					instr 'mov', e2, e
				end
				@state.cache[e2] = oldval if oldval and e.kind_of? ModRM
				e2
			elsif type.float?
				raise 'float unhandled'
			else raise "cannot cast #{e} to #{type}"
			end
		elsif e.kind_of? Address
			make_volatile resolve_address(e), type, rsz
		elsif e.kind_of? Expression
			if type.integral? or type.pointer?
				e2 = inuse findreg
				instr 'mov', e2, e
				e2
			elsif type.float?
				raise 'float unhandled'
			else raise "cannot cast #{e} to #{type}"
			end
		else
			e
		end
	end
# copies the arg e to a volatile location (register/composite) if it is not already
# unuses the old storage
# may return a register bigger than the type size (eg __int8 are stored in full reg size)
copies the arg e to a volatile location (register/composite) if it is not already
unuses the old storage
may return a register bigger than the type size
copies the arg e to a volatile location ( register / composite ) if it is not already unuses the old storage may return a register bigger than the type size
def make_volatile(e, type, rsz=@cpusz)
		if e.kind_of? ModRM or @state.bound.index(e)
			if type.integral? or type.pointer?
				oldval = @state.cache[e]
				unuse e
				sz = typesize[type.pointer? ? :ptr : type.name]*8
				if sz < @cpusz or sz < rsz or e.sz < rsz
					e2 = inuse findreg(rsz)
					op = ((type.specifier == :unsigned) ? 'movzx' : 'movsx')
					op = 'mov' if e.sz == e2.sz
					if e2.sz == 64 and e.sz == 32
						if op == 'movsx'
							instr 'movsxd', e2, e
						else
							instr 'mov', Reg.new(e2.val, 32), e
						end
					else
						instr op, e2, e
					end
				else
					e2 = inuse findreg(sz)
					instr 'mov', e2, e
				end
				@state.cache[e2] = oldval if oldval and e.kind_of? ModRM
				e2
			elsif type.float?
				raise 'float unhandled'
			else raise "cannot cast #{e} to #{type}"
			end
		elsif e.kind_of? Address
			make_volatile resolve_address(e), type, rsz
		elsif e.kind_of? Expression
			if type.integral? or type.pointer?
				e2 = inuse findreg
				instr 'mov', e2, e
				e2
			elsif type.float?
				raise 'float unhandled'
			else raise "cannot cast #{e} to #{type}"
			end
		else
			e
		end
	end
def make_volatile ( e , type , rsz = @cpusz ) if e . kind_of? ModRM or @state . bound . index ( e ) if type . integral? or type . pointer? oldval = @state . cache [ e ] unuse e sz = typesize [ type . pointer? ? :ptr : type . name ] * 8 if sz < @cpusz or sz < rsz or e . sz < rsz e2 = inuse findreg ( rsz ) op = ( ( type . specifier == :unsigned ) ? 'movzx' : 'movsx' ) op = 'mov' if e . sz == e2 . sz if e2 . sz == 64 and e . sz == 32 if op == 'movsx' instr 'movsxd' , e2 , e else instr 'mov' , Reg . new ( e2 . val , 32 ) , e end else instr op , e2 , e end else e2 = inuse findreg ( sz ) instr 'mov' , e2 , e end @state . cache [ e2 ] = oldval if oldval and e . kind_of? ModRM e2 elsif type . float? raise 'float unhandled' else raise "cannot cast #{e} to #{type}" end elsif e . kind_of? Address make_volatile resolve_address ( e ) , type , rsz elsif e . kind_of? Expression if type . integral? or type . pointer? e2 = inuse findreg instr 'mov' , e2 , e e2 elsif type . float? raise 'float unhandled' else raise "cannot cast #{e} to #{type}" end else e end end
copies the arg e to a volatile location (register/composite) if it is not already
unuses the old storage
may return a register bigger than the type size (eg __int8 are stored in full reg size)
copies the arg e to a volatile location ( register / composite ) if it is not already unuses the old storage may return a register bigger than the type size ( eg __int8 are stored in full reg size )
e
type
rsz