Example #1
0
        protected override void Compile(CodeContext c)
        {
            var l1 = c.Label();
            var l2 = c.Label();
            var l3 = c.Label();
            var l4 = c.Label();
            var l5 = c.Label();
            var l6 = c.Label();
            var l7 = c.Label();

            var v0 = c.UInt32("v0");
            var v1 = c.UInt32("v1");

            c.Bind(l2);
            c.Bind(l3);

            c.Jmp(l1);

            c.Bind(l5);
            c.Mov(v0, 0);

            c.Bind(l6);
            c.Jmp(l3);
            c.Mov(v1, 1);
            c.Jmp(l1);

            c.Bind(l4);
            c.Jmp(l2);
            c.Bind(l7);
            c.Add(v0, v1);

            c.Align(AligningMode.Code, 16);
            c.Bind(l1);
            c.Ret();
        }
Example #2
0
        protected override void Compile(CodeContext c)
        {
            var v1 = c.Int32("v1");
            var v2 = c.Int32("v2");

            c.SetArgument(0, v1);
            c.SetArgument(1, v2);

            var l1 = c.Label();
            var l2 = c.Label();
            var l3 = c.Label();
            var l4 = c.Label();

            c.Jmp(l1);
            c.Bind(l2);
            c.Jmp(l4);
            c.Bind(l1);

            c.Cmp(v1, v2);
            c.Jg(l3);

            c.Mov(v1, 1);
            c.Jmp(l2);

            c.Bind(l3);
            c.Mov(v1, 2);
            c.Jmp(l2);

            c.Bind(l4);

            c.Ret(v1);
        }
Example #3
0
        protected override void Compile(CodeContext c)
        {
            var v1 = c.Int32("v1");
            var v2 = c.Int32("v2");

            c.SetArgument(0, v1);
            c.SetArgument(1, v2);

            var counter = c.Int32("counter");

            var l1   = c.Label();
            var loop = c.Label();
            var exit = c.Label();

            c.Cmp(v1, v2);
            c.Jg(l1);

            c.Mov(counter, 0);

            c.Bind(loop);
            c.Mov(v1, counter);

            c.Inc(counter);
            c.Cmp(counter, 1);
            c.Jle(loop);
            c.Jmp(exit);

            c.Bind(l1);
            c.Mov(v1, 2);

            c.Bind(exit);
            c.Ret(v1);
        }
Example #4
0
        protected override void Compile(CodeContext c)
        {
            var l1 = c.Label();
            var l2 = c.Label();
            var l3 = c.Label();

            c.Jmp(l2);

            c.Bind(l1);
            c.Jmp(l3);

            c.Bind(l2);
            c.Jmp(l1);

            c.Bind(l3);

            c.Ret();
        }
Example #5
0
        protected override void Compile(CodeContext c)
        {
            var l1 = c.Label();
            var l2 = c.Label();

            var v0 = c.UInt32("v0");
            var v1 = c.UInt32("v1");

            c.Jmp(l1);
            c.Bind(l2);
            c.Mov(v0, 1);
            c.Mov(v1, 2);
            c.Cmp(v0, v1);
            c.Jz(l2);
            c.Jmp(l1);

            c.Bind(l1);
            c.Ret();
        }