public void MarkSymbolReference(Symbol symbol, SymbolReferenceType type) { References.Add(new SymbolReference(this) { Symbol = symbol, Type = type }); }
public int GetImmediate(string arg, SymbolReferenceType type) { int val = 0; if (arg.StartsWith("0x")) { val = ushort.Parse(arg.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier); } else if (!int.TryParse(arg, out val)) { // Add a symbol reference MarkSymbolReference(arg, type); } if (type == SymbolReferenceType.ImmediateLower) { return((int)((ushort)val)); } else if (type == SymbolReferenceType.ImmediateUpper) { return((int)((ushort)(val >> 16))); } else { return(val); } }
public void MarkSymbolReference(string symbol, SymbolReferenceType type) { // The SymbolReference constructor automatically // initializes the section and the offset. References.Add(new SymbolReference(this) { Name = symbol, Type = type }); }
public void EmitInstruction(string name, string symbol, SymbolReferenceType type, params int[] args) { MarkSymbolReference(symbol, type); var def = InstructionSet.Instructions[name]; var ins = Instruction.FromDefinition(def, args); CurrentSection.Stream.Write(BitConverter.GetBytes(ins.Encode()), 0, 4); CurrentSection.Offset += 4; }