示例#1
0
 public void MarkSymbolReference(Symbol symbol, SymbolReferenceType type)
 {
     References.Add(new SymbolReference(this)
     {
         Symbol = symbol, Type = type
     });
 }
示例#2
0
        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);
            }
        }
示例#3
0
 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
     });
 }
示例#4
0
        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;
        }