public void HandleIfStatement(ASTNode node) { // handle condition with the bne command // add new entry to jump table // write code for associated block string[] splitConditionAddress = ConditionResultAddress.Split(" "); int conditionResult = (int)EvaluateBooleanSubtree(node.Descendants[0]); Image.WriteByte("A9"); Image.WriteByte(conditionResult.ToString("X2")); Image.WriteByte("8D"); Image.WriteByte(splitConditionAddress[0]); Image.WriteByte(splitConditionAddress[1]); Image.WriteByte("A2"); Image.WriteByte("01"); Image.WriteByte("EC"); Image.WriteByte(splitConditionAddress[0]); Image.WriteByte(splitConditionAddress[1]); JumpTableEntry jumpEntry = JumpTable.NewJumpEntry(); Image.WriteByte("D0"); Image.WriteByte(jumpEntry.Name); HandleSubtree(node.Descendants[1]); jumpEntry.JumpLength = JumpLength; JumpLength = 0; }
public CodeGenerator(SemanticAnalyser semanticAnalyser, DiagnosticCollection diagnostics, Session session) { SemanticAnalyser = semanticAnalyser; Diagnostics = diagnostics; CurrentSession = session; StaticTemp = new TempTable(); JumpTable = new JumpTable(); Image = new RuntimeImage(); }