/// <summary> /// Converts the entry to a method. /// </summary> public void ConvertEntryToMethod(ITableEntry entry) { Method methodEntry = entry as TableEntry; methodEntry.typeOfEntry = EntryType.methodEntry; methodEntry.returnType = TypeReturn; methodEntry.sizeOfLocalVars = LocalVarsSize; methodEntry.numOfParameters = ParameterNum; methodEntry.sizeOfParameterVars = ParameterVarsSize; methodEntry.parameterTypes = ParameterTypes; ASMProcs.Enqueue(methodEntry); // saves the method for asm proc generation later Upsert(methodEntry); }
private void GenerateProcsASM() { Method proc = new Method(); while (ASMProcs.Count > 0) { proc = ASMProcs.Dequeue(); AssemblyFile.AddLine(""); AssemblyFile.AddLine($"{proc.lexeme} PROC"); AssemblyFile.AddLine(" push bp"); AssemblyFile.AddLine(" mov bp, sp"); AssemblyFile.AddLine($" sub sp, {proc.sizeOfLocalVars}"); GenerateProcBodyASM(); AssemblyFile.AddLine($" add sp, {proc.sizeOfLocalVars}"); AssemblyFile.AddLine(" pop bp"); AssemblyFile.AddLine($" ret {proc.sizeOfParameterVars - 4}"); AssemblyFile.AddLine($"{proc.lexeme} ENDP"); } }