Esempio n. 1
0
        private Dictionary<Symbol, AssembledSegment> symbolSegments;        // The segment to which a symbol belongs.

        public X86Assembler(IntelArchitecture arch, Address addrBase, List<EntryPoint> entryPoints)
        {
            this.arch = arch;
            this.Platform = new MsdosPlatform(null, arch);
            this.addrBase = addrBase;
            this.entryPoints = entryPoints;
            this.defaultWordSize = arch.WordWidth;
            this.textEncoding = Encoding.GetEncoding("ISO_8859-1");
            symtab = new SymbolTable();
            importReferences = new Dictionary<Address, ImportReference>();
            segments = new List<AssembledSegment>();
            mpNameToSegment = new Dictionary<string, AssembledSegment>();
            symbolSegments = new Dictionary<Symbol, AssembledSegment>();
            this.SegmentOverride = RegisterStorage.None;

            unknownSegment = new AssembledSegment(new Emitter(), symtab.DefineSymbol("", 0));
            segments.Add(unknownSegment);

            SwitchSegment(unknownSegment);

            SetDefaultWordWidth(defaultWordSize);
        }
Esempio n. 2
0
 private void SwitchSegment(AssembledSegment unknownSegment)
 {
     currentSegment = unknownSegment;
     emitter = unknownSegment.Emitter;
     modRm = new ModRmBuilder(defaultWordSize, emitter);
 }
Esempio n. 3
0
 private AssembledSegment GetSymbolSegmentReference(Symbol sym)
 {
     AssembledSegment seg;
     if (symbolSegments.TryGetValue(sym, out seg))
         return seg;
     seg = new AssembledSegment(emitter, null);
     symbolSegments.Add(sym, seg);
     return seg;
 }
Esempio n. 4
0
 public void Segment(string segmentName)
 {
     AssembledSegment seg;
     if (!mpNameToSegment.TryGetValue(segmentName, out seg))
     {
         var sym = symtab.DefineSymbol(segmentName, 0);
         seg = new AssembledSegment(new Emitter(), sym);
         segments.Add(seg);
     }
     SwitchSegment(seg);
 }