Example #1
0
        public static Command FunctionCall(
            string name, int argc, LabelGenerator generator)
        {
            var label = generator.Generate("ret");

            return(new Command(
                       $"call {name} {argc}",
                       new[]
            {
                label.Address,
                "D=A",
                "@R13",
                "M=D",

                '@' + argc.ToString(),
                "D=A",
                "@R14",
                "M=D",

                '@' + name,
                "D=A",
                "@R15",
                "M=D",

                "@CALL",
                "0;JMP",

                label.Declaration
            }));
        }
Example #2
0
 public static Command GreateThan(LabelGenerator generator) =>
 Compare("gt", "JLT", generator.Generate("gt"));
Example #3
0
 public static Command LessThan(LabelGenerator generator) =>
 Compare("lt", "JGT", generator.Generate("lt"));
Example #4
0
 public static Command Equal(LabelGenerator generator) =>
 Compare("eq", "JEQ", generator.Generate("eq"));