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 })); }
public static Command GreateThan(LabelGenerator generator) => Compare("gt", "JLT", generator.Generate("gt"));
public static Command LessThan(LabelGenerator generator) => Compare("lt", "JGT", generator.Generate("lt"));
public static Command Equal(LabelGenerator generator) => Compare("eq", "JEQ", generator.Generate("eq"));