Esempio n. 1
0
        private void Given_Code(params uint [] uInstrs)
        {
            var writer = new BeImageWriter();

            foreach (uint uInstr in uInstrs)
            {
                writer.WriteBeUInt32(uInstr);
            }
            var mem     = new MemoryArea(Address.Ptr64(0x0010_0000), writer.ToArray());
            var seg     = new ImageSegment("code", mem, AccessMode.ReadWriteExecute);
            var segmap  = new SegmentMap(mem.BaseAddress, seg);
            var program = new Program(segmap, arch, new DefaultPlatform(sc, arch));

            var envEmu = new DefaultPlatformEmulator();

            emu = (Reko.Arch.PowerPC.PowerPcEmulator)arch.CreateEmulator(segmap, envEmu);
            emu.InstructionPointer = program.ImageMap.BaseAddress;
            emu.ExceptionRaised   += (sender, e) => { throw e.Exception; };
        }
Esempio n. 2
0
        private void Given_Code(Action <Assembler> p)
        {
            var asm = new Assembler(sc, arch, Address.Ptr16(0x0800), new List <ImageSymbol>());

            p(asm);
            var program = asm.GetImage();

            program.SegmentMap.AddSegment(
                new ByteMemoryArea(Address.Ptr16(0), new byte[256]),
                "ZeroPage",
                AccessMode.ReadWriteExecute);
            program.SegmentMap.AddSegment(
                new ByteMemoryArea(Address.Ptr16(0x100), new byte[0x200]),
                "Low memory",
                AccessMode.ReadWriteExecute);

            var envEmu = new DefaultPlatformEmulator();

            emu = (Mos6502Emulator)arch.CreateEmulator(program.SegmentMap, envEmu);
            emu.InstructionPointer = program.ImageMap.BaseAddress;
            emu.WriteRegister(Registers.s, 0xFF);
            emu.ExceptionRaised += (sender, e) => { throw e.Exception; };
        }