Ejemplo n.º 1
0
        public void Visit(GreaterThan m)
        {
            //compare and push 1 if carry and zero are 0
            //zc
            //00 = a > b
            //01 = a < b
            //10 = a == b
            //push a 1 if zc == 0

            sw.WriteLine("\tnop ;a > b");
            sw.WriteLine("\tpop bx");
            sw.WriteLine("\tpop ax");
            sw.WriteLine("\tcmp ax,bx");
            string psh = GetNextLabel();
            string yes = GetNextLabel();

            //sw.WriteLine("\tbls 4 ; C or Z is set - load a #0");
            sw.WriteLine("\tja " + yes.Substring(0, yes.Length - 1));
            sw.WriteLine("\tmov ax,0");
            sw.WriteLine("\tjmp " + psh.Substring(0, psh.Length - 1));
            sw.WriteLine(yes);
            sw.WriteLine("\tmov ax,1");
            sw.WriteLine(psh);
            sw.WriteLine("\tpush ax");
        }
Ejemplo n.º 2
0
        public void Visit(GreaterThan m)
        {/*
          * Console.WriteLine("pop stack into a");
          * Console.WriteLine("pop stack into b");
          * Console.WriteLine("compare a,b");
          * Console.WriteLine("push a 1 if carry flag set");
          */
            PopAndCompare();

            //carry flag is not set or the
            //zero flag is set
            //zc
            //00 - less than
            //01 - greater than (no)
            //11 - equal
            //need to determine z + c == 0
            sw.WriteLine("\tphp ; flags -> a");
            sw.WriteLine("\tpla");
            sw.WriteLine("\tand #3 ; isolate z and c for greater than");
            sw.WriteLine("\tcmp #1 ; test zc = 01");
            sw.WriteLine("\tphp ; zc -> a");
            sw.WriteLine("\tpla");
            sw.WriteLine("\tlsr a ; right align z");
            sw.WriteLine("\tand #1 ; isolate z");
            sw.WriteLine("\tpha ; push result of gt");
        }
Ejemplo n.º 3
0
        public void Visit(GreaterThan m)
        {
            //compare and push 1 if carry and zero are 0
            //zc
            //00 = a > b
            //01 = a < b
            //10 = a == b
            //push a 1 if zc == 0

            sw.WriteLine("\t;a > b");
            sw.WriteLine("\tpuls a");
            sw.WriteLine("\tsta temp");
            sw.WriteLine("\tpuls a");
            sw.WriteLine("\tcmpa temp");
            string psh  = GetNextLabel();
            string zero = GetNextLabel();

            //sw.WriteLine("\tbls #4 ; C or Z is set - load a #0");
            sw.WriteLine("\tbls " + zero);
            sw.WriteLine("\tlda #1");
            sw.WriteLine("\tbra " + psh);
            sw.WriteLine(zero);
            sw.WriteLine("\tlda #0");
            sw.WriteLine(psh);
            sw.WriteLine("\tpshs a");
        }
Ejemplo n.º 4
0
        public void Visit(GreaterThan m)
        {
            //compare and push 1 if carry and zero are 0
            //zc
            //00 = a > b
            //01 = a < b
            //10 = a == b
            //push a 1 if zc == 0

            sw.WriteLine(Tabs() + "// ;a > b");
            sw.WriteLine(Tabs() + "param2 = param_stack_pop();");
            sw.WriteLine(Tabs() + "param1 = param_stack_pop();");
            sw.WriteLine(Tabs() + "param_stack.push((short)(param1 > param2));");
        }
Ejemplo n.º 5
0
 public void Visit(GreaterThan m)
 {
     //push a 1 if carry = 0 and z == 0
     sw.WriteLine("\t; a > b");
     sw.WriteLine("\tpop bc");
     sw.WriteLine("\tpop af");
     sw.WriteLine("\tcp b");
     sw.WriteLine("\tjr c,6 ; skip to push 0");
     sw.WriteLine("\tdb 38h ; jrc");
     sw.WriteLine("\tdb 6;");
     sw.WriteLine("\tld a,1");
     sw.WriteLine("\tjr z,4 ; skip to push 0");
     sw.WriteLine("\tdb 28h; jrz");
     sw.WriteLine("\tdb 4;");
     sw.WriteLine("\tld a,1");
     sw.WriteLine("\t;jr 2");
     sw.WriteLine("\tdb 18h ; jr");
     sw.WriteLine("\tdb  2");
     sw.WriteLine("\tld  a,0");
     sw.WriteLine("\tpush af");
 }