private IEnumerable <string> ProcessCall(Vmcmd vmcmd, Idgen idgen, string stFunc) { var lblNext = idgen.Id("after_call"); yield return("//r14: hány argumentum van a veremben"); yield return("//r15: hova kell ugrani"); yield return("//D: hova kell visszatérni"); if (vmcmd.I == 0) { yield return("@R14"); yield return("M=0"); } else if (vmcmd.I == 1) { yield return("@R14"); yield return("M=1"); } else { yield return("@" + vmcmd.I); yield return("D=A"); yield return("@R14"); yield return("M=D"); } yield return("@" + idgen.Fun(vmcmd.StFn)); yield return("D=A"); yield return("@R15"); yield return("M=D"); yield return("@" + lblNext); yield return("D=A"); yield return("@" + lblFunCall); yield return("D;JMP"); yield return("(" + lblNext + ")"); }
private static IEnumerable <string> ProcessFunction(Vmcmd vmcmd, Idgen idgen, string stFunc) { yield return("(" + idgen.Fun(vmcmd.StFn) + ")"); for (int k = 0; k < vmcmd.I; k++) { yield return("//push 0"); yield return("@SP"); yield return("AM=M+1"); yield return("A=A-1"); yield return("M=0"); } }