/// <summary> /// Load a Basic PRG. /// </summary> /// <param name="imageBytes"></param> /// <returns></returns> private Program LoadPrg(byte[] imageBytes) { var stm = new MemoryStream(); ushort preferredAddress = LoadedImage.ReadLeUInt16(imageBytes, 0); ushort alignedAddress = (ushort)(preferredAddress & ~0xF); int pad = preferredAddress - alignedAddress; while (pad-- > 0) { stm.WriteByte(0); } stm.Write(imageBytes, 2, imageBytes.Length - 2); var loadedBytes = stm.ToArray(); var image = new LoadedImage( Address.Ptr16(alignedAddress), loadedBytes); var rdr = new C64BasicReader(image, 0x0801); var prog = rdr.ToSortedList(line => (ushort)line.Address.ToLinear(), line => line); var arch = new C64Basic(prog); image = new LoadedImage( Address.Ptr16(prog.Keys[0]), new byte[0xFFFF]); var program = new Program( image, image.CreateImageMap(), arch, new C64Platform(Services, null)); program.EntryPoints.Add(new EntryPoint(image.BaseAddress, arch.CreateProcessorState())); return(program); }
public override Program Load(Address addrLoad, IProcessorArchitecture arch, IPlatform platform) { var stm = new MemoryStream(); ushort preferredAddress = ByteMemoryArea.ReadLeUInt16(RawImage, 0); ushort alignedAddress = (ushort)(preferredAddress & ~0xF); int pad = preferredAddress - alignedAddress; while (pad-- > 0) { stm.WriteByte(0); } stm.Write(RawImage, 2, RawImage.Length - 2); var loadedBytes = stm.ToArray(); var image = new ByteMemoryArea( Address.Ptr16(alignedAddress), loadedBytes); var rdr = new C64BasicReader(image, 0x0801); var lines = rdr.ToSortedList(line => line.LineNumber, line => line); var cfgSvc = Services.RequireService <IConfigurationService>(); arch = new C64Basic(Services, lines); platform = cfgSvc.GetEnvironment("c64").Load(Services, arch); var arch6502 = cfgSvc.GetArchitecture("m6502"); SegmentMap segMap = CreateSegmentMap(platform, image, lines); var program = new Program(segMap, arch, platform); program.Architectures.Add(arch6502.Name, arch6502); var addrBasic = lines.Values[0].Address; var sym = ImageSymbol.Procedure(arch, addrBasic, state: arch.CreateProcessorState()); program.EntryPoints.Add(sym.Address, sym); AddLineNumberSymbols(lines, program); return(program); }
/// <summary> /// Load a Basic PRG. /// </summary> /// <param name="imageBytes"></param> /// <returns></returns> private Program LoadPrg(byte[] imageBytes) { var stm = new MemoryStream(); ushort preferredAddress = MemoryArea.ReadLeUInt16(imageBytes, 0); ushort alignedAddress = (ushort)(preferredAddress & ~0xF); int pad = preferredAddress - alignedAddress; while (pad-- > 0) { stm.WriteByte(0); } stm.Write(imageBytes, 2, imageBytes.Length - 2); var loadedBytes = stm.ToArray(); var image = new MemoryArea( Address.Ptr16(alignedAddress), loadedBytes); var rdr = new C64BasicReader(image, 0x0801); var lines = rdr.ToSortedList(line => (ushort)line.Address.ToLinear(), line => line); var cfgSvc = Services.RequireService <IConfigurationService>(); var arch6502 = (Mos6502ProcessorArchitecture)cfgSvc.GetArchitecture("m6502"); var arch = new C64Basic(lines); var platform = cfgSvc.GetEnvironment("c64").Load(Services, arch); var segMap = platform.CreateAbsoluteMemoryMap(); segMap.AddSegment(image, "code", AccessMode.ReadWriteExecute); var program = new Program(segMap, arch, platform); program.Architectures.Add(arch6502.Name, arch6502); var addrBasic = Address.Ptr16(lines.Keys[0]); var sym = ImageSymbol.Procedure(arch, addrBasic, state: arch.CreateProcessorState()); program.EntryPoints.Add(sym.Address, sym); return(program); }
private Program LoadPrg(IServiceProvider services) { // Many of these programs use all of the // C64 memory, so be generous. var image = new ByteMemoryArea(Address.Ptr16(0x800), new byte[0xF800 - 0x800]); var src = this.GetBytes(); Array.Copy(src, 0, image.Bytes, (int)(this.LoadAddress - (ushort)image.BaseAddress.ToLinear()), src.Length); var rdr = new C64BasicReader(image, 0x0801); var lines = rdr.ToSortedList(line => (ushort)line.LineNumber, line => line); var cfgSvc = services.RequireService <IConfigurationService>(); var arch6502 = cfgSvc.GetArchitecture("m6502") !; var arch = new C64Basic(services, lines); var platform = cfgSvc.GetEnvironment("c64").Load(services, arch); var segMap = platform.CreateAbsoluteMemoryMap() !; segMap.AddSegment(image, "code", AccessMode.ReadWriteExecute); var program = new Program(segMap, arch, platform); program.Location = ImageLocation; program.Architectures.Add(arch6502.Name, arch6502); var addrBasic = Address.Ptr16(lines.Keys[0]); var sym = ImageSymbol.Procedure(arch, addrBasic, state: arch.CreateProcessorState()); program.EntryPoints.Add(sym.Address, sym); return(program); }
/// <summary> /// Load a Basic PRG. /// </summary> /// <param name="imageBytes"></param> /// <returns></returns> private Program LoadPrg(byte[] imageBytes) { var stm = new MemoryStream(); ushort preferredAddress = MemoryArea.ReadLeUInt16(imageBytes, 0); ushort alignedAddress = (ushort)(preferredAddress & ~0xF); int pad = preferredAddress - alignedAddress; while (pad-- > 0) { stm.WriteByte(0); } stm.Write(imageBytes, 2, imageBytes.Length - 2); var loadedBytes = stm.ToArray(); var image = new MemoryArea( Address.Ptr16(alignedAddress), loadedBytes); var rdr = new C64BasicReader(image, 0x0801); var prog = rdr.ToSortedList(line => (ushort)line.Address.ToLinear(), line => line); var arch = new C64Basic(prog); image = new MemoryArea( Address.Ptr16(prog.Keys[0]), new byte[0xFFFF]); var program = new Program( new SegmentMap( image.BaseAddress, new ImageSegment("code", image, AccessMode.ReadWriteExecute)), arch, new C64Platform(Services, null)); var sym = ImageSymbol.Procedure(arch, image.BaseAddress, state: arch.CreateProcessorState()); program.EntryPoints.Add(sym.Address, sym); return(program); }
public C64BasicRewriter(C64Basic arch, Address address, SortedList <ushort, C64BasicInstruction> prog, IRewriterHost host) { this.arch = arch; this.address = address; this.prog = prog; this.host = host; this.strType = StringType.LengthPrefixedStringType(PrimitiveType.Char, PrimitiveType.Byte); }
public C64BasicRewriter( C64Basic arch, Address address, SortedList <ushort, C64BasicInstruction> lines, IDictionary <Address, C64BasicInstruction> instrs, IRewriterHost host) { this.address = address; this.Lines = lines; this.instrs = instrs; this.host = host; this.strType = StringType.LengthPrefixedStringType(PrimitiveType.Char, PrimitiveType.Byte); }
private Program LoadPrg(T64FileEntry selectedFile) { var image = new ByteMemoryArea( Address.Ptr16(selectedFile.LoadAddress), selectedFile.GetBytes()); var rdr = new C64BasicReader(image, 0x0801); var lines = rdr.ToSortedList(line => (ushort)line.LineNumber, line => line); var cfgSvc = Services.RequireService <IConfigurationService>(); var arch6502 = cfgSvc.GetArchitecture("m6502") !; var arch = new C64Basic(Services, lines); var platform = cfgSvc.GetEnvironment("c64").Load(Services, arch); var segMap = platform.CreateAbsoluteMemoryMap() !; segMap.AddSegment(image, "code", AccessMode.ReadWriteExecute); var program = new Program(segMap, arch, platform); program.Architectures.Add(arch6502.Name, arch6502); var addrBasic = Address.Ptr16(lines.Keys[0]); var sym = ImageSymbol.Procedure(arch, addrBasic, state: arch.CreateProcessorState()); program.EntryPoints.Add(sym.Address, sym); return(program); }
public void Setup() { lines = new SortedList<ushort, C64BasicInstruction>(); arch = new C64Basic(lines); m = new BasicProcessor(lines); }
/// <summary> /// Load a Basic PRG. /// </summary> /// <param name="imageBytes"></param> /// <returns></returns> private Program LoadPrg(byte[] imageBytes) { var stm = new MemoryStream(); ushort preferredAddress = LoadedImage.ReadLeUInt16(imageBytes, 0); ushort alignedAddress = (ushort) (preferredAddress & ~0xF); int pad = preferredAddress - alignedAddress; while (pad-- > 0) stm.WriteByte(0); stm.Write(imageBytes, 2, imageBytes.Length - 2); var loadedBytes = stm.ToArray(); var image = new LoadedImage( Address.Ptr16(alignedAddress), loadedBytes); var rdr = new C64BasicReader(image, 0x0801); var prog = rdr.ToSortedList(line => (ushort)line.Address.ToLinear(), line => line); var arch = new C64Basic(prog); image = new LoadedImage( Address.Ptr16(prog.Keys[0]), new byte[0xFFFF]); var program = new Program( image, image.CreateImageMap(), arch, new C64Platform(Services, null)); program.EntryPoints.Add(new EntryPoint(image.BaseAddress, arch.CreateProcessorState())); return program; }
public C64BasicState(C64Basic arch) { this.arch = arch; }
public C64BasicState(C64BasicState that) : base(that) { this.arch = that.arch; }