private void resolveDeferredArguments() { foreach (ArgumentDeferred deferred in m_deferredArguments) { ArgumentVisitor argumentVisitor = new ArgumentVisitor(m_equValues, allowDefer: false); Argument argument = argumentVisitor.Visit(deferred.m_context); int index = deferred.m_location; foreach (byte b in argument.generateBytes(deferred.m_opcode, deferred.m_relativeTo)) { Debug.Assert(m_objectCode[index] == 0xDF); Console.WriteLine("{0:X2} -> {1:X2}", m_objectCode[index], b); m_objectCode[index] = b; index++; } } }
public override object VisitStmtOpcode(AsmParser.StmtOpcodeContext context) { string opcode = context.opcode.Text.ToUpper(); Argument argument = null; if (context.argument() != null) { ArgumentVisitor argumentVisitor = new ArgumentVisitor(m_equValues, allowDefer: true); argument = argumentVisitor.Visit(context.argument()); } else { argument = new ArgumentInherent(); } switch (opcode) { case "ORG": // TODO break; case "END": Console.WriteLine("END, program start at {0}", argument); break; default: List <Opcode> candidates = Opcode.lookUpOpcode(opcode); if (candidates.Count == 0) { throw new InvalidOperationException("Unsupported opcode '" + opcode + "'"); } Console.WriteLine("{0} {1}", opcode, argument); foreach (Opcode candidate in candidates) { Console.WriteLine(" {0}", candidate); } generateInstruction(candidates, argument); break; } return(null); }