protected override void Compile(CodeContext c) { var op = c.Int32("op"); var a = c.Int32("a"); var b = c.Int32("b"); var zero = c.Label(); var add = c.Label(); var sub = c.Label(); var mul = c.Label(); var div = c.Label(); c.SetArgument(0, op); c.SetArgument(1, a); c.SetArgument(2, b); c.Cmp(op, 0); c.Jz(add); c.Cmp(op, 1); c.Jz(sub); c.Cmp(op, 2); c.Jz(mul); c.Cmp(op, 3); c.Jz(div); c.Bind(zero); c.Xor(a, a); c.Ret(a); c.Bind(add); c.Add(a, b); c.Ret(a); c.Bind(sub); c.Sub(a, b); c.Ret(a); c.Bind(mul); c.Imul(a, b); c.Ret(a); c.Bind(div); c.Cmp(b, 0); c.Jz(zero); var z = c.Int32("z"); c.Xor(z, z); c.Idiv(z, a, b); c.Ret(a); }
protected override void Compile(CodeContext c) { var dstHi = c.IntPtr("dstHi"); var dstLo = c.IntPtr("dstLo"); var vLo = c.Int32("vLo"); var src = c.Int32("src"); c.SetArgument(0, dstHi); c.SetArgument(1, dstLo); c.SetArgument(2, vLo); c.SetArgument(3, src); var vHi = c.Int32("vHi"); c.Imul(vHi, vLo, src); c.Mov(Memory.DWord(dstHi), vHi); c.Mov(Memory.DWord(dstLo), vLo); }
protected override void Compile(CodeContext c) { var dst = c.IntPtr("dst"); var src = c.IntPtr("src"); c.SetArgument(0, dst); c.SetArgument(1, src); for (var i = 0; i < 4; i++) { var x = c.Int32("x"); var y = c.Int32("y"); var hi = c.Int32("hi"); c.Mov(x, Memory.DWord(src, 0)); c.Mov(y, Memory.DWord(src, 4)); c.Imul(hi, x, y); c.Add(Memory.DWord(dst, 0), hi); c.Add(Memory.DWord(dst, 4), x); } }