metasm/cpu/ia32/compile_c.rb in metasm-1.0.2 vs metasm/cpu/ia32/compile_c.rb in metasm-1.0.3
- old
+ new
@@ -265,10 +265,15 @@
n = type.integral? ? type.name : :ptr
if (sz = typesize[n]*8) < @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
+ elsif e.sz > sz
+ e2 = inuse findreg(sz)
+ el, eh = get_composite_parts(e)
+ e = el
+ op = 'mov'
else
e2 = inuse findreg(sz)
op = 'mov'
end
instr op, e2, e
@@ -777,10 +782,13 @@
instr 'mov', l, Reg.new(reg, 8)
end
else
instr 'mov', l, Reg.new(r.val, l.sz)
end
+ elsif r.kind_of? Composite
+ rl, rh = get_composite_parts r
+ instr 'mov', l, rl
else
instr 'mov', l, r
end
end
elsif expr.type.float?
@@ -1327,29 +1335,37 @@
end
r = make_volatile(r, expr.type) if r.kind_of? ModRM and l.kind_of? ModRM
unuse l, r
if expr.lexpr.type.integral?
if expr.lexpr.type.name == :__int64 and @cpusz != 64
- raise # TODO
+ raise "unsupported 64bit comparison #{expr}" # TODO
end
instr 'cmp', l, r
elsif expr.lexpr.type.float?
- raise # TODO
+ raise "unsupported float comparison #{expr}" # TODO
instr 'fcmpp', l, r
else raise 'bad comparison ' + expr.to_s
end
op = 'j' + getcc(o, expr.lexpr.type)
instr op, Expression[target]
when :'!'
r = c_cexpr_inner(expr.rexpr)
r = make_volatile(r, expr.rexpr.type)
unuse r
+ if r.kind_of? Composite
+ r, rh = get_composite_parts(r)
+ instr 'or', r, rh
+ end
instr 'test', r, r
instr 'jz', Expression[target]
else
r = c_cexpr_inner(expr)
r = make_volatile(r, expr.type)
unuse r
+ if r.kind_of? Composite
+ r, rh = get_composite_parts(r)
+ instr 'or', r, rh
+ end
instr 'test', r, r
instr 'jnz', Expression[target]
end
end