예제 #1
0
        public void Visit(LessThanEquals m)
        {
            //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 yes  = GetNextLabel();
            string push = GetNextLabel();

            sw.WriteLine("\tjbe " + yes.Substring(0, yes.Length - 1) + " ; C or Z is set - load a #1");
            sw.WriteLine("\tmov ax,0");
            sw.WriteLine("\tjmp " + push.Substring(0, push.Length - 1));
            sw.WriteLine(yes);
            sw.WriteLine("\tmov ax,1");
            sw.WriteLine(push);
            sw.WriteLine("\tpush ax");
        }
예제 #2
0
        public void Visit(LessThanEquals m)
        {
            //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 one  = GetNextLabel();
            string push = GetNextLabel();

            sw.WriteLine("\tbls " + one + " ; C or Z is set - load a #1");
            sw.WriteLine("\tlda #0");
            sw.WriteLine("\tbra " + push);
            sw.WriteLine(one);
            sw.WriteLine("\tlda #1");
            sw.WriteLine(push);
            sw.WriteLine("\tpshs a");
        }