public void TestAs() { var config = Toolchain.Configuration.FromEnvironment(); using (var test = Toolchain.Assemble(config, "la $4,ENTRY_POINT")) using (var elf = Toolchain.Link(config, new[] { test.Path }, Toolchain.GenerateLinkerScript(0x80809999))) { var binary = Toolchain.ToBinary( config, elf.Path ); } }
public static IEnumerable <AssembledInstruction> AssembleSource(Toolchain.Configuration tcConfig, string source, AssembleSourceOptions options = null) { var assembled = GetChunksWithCommon(source) .Select(x => new { x.Assembly, x.RomAddress, x.RamAddress, Out = Toolchain.Assemble(tcConfig, x.Assembly) }) .ToArray(); var linkerParts = assembled.Select(x => (x.Out.Path, x.RamAddress)); var linkerDetails = Toolchain.GenerateLinkerScript(linkerParts); using (var elf = Toolchain.Link(tcConfig, new[] { "-q" }, linkerDetails.script)) { try { return(linkerDetails.chunkFilter .Zip(assembled, (filter, asm) => new { filter, asm.RamAddress, asm.RomAddress }) .SelectMany(x => Toolchain.ToBinary(tcConfig, elf.Path, x.filter.SelectMany(y => new[] { "-j", y })) .ToInstructions() .Select((y, i) => new AssembledInstruction(x.RomAddress + (uint)i * 4, x.RamAddress + (uint)i * 4, y)) ) .ToArray()); } finally { foreach (var x in assembled) { x.Out.Dispose(); } if (options?.PreserveElfAt != null) { File.Copy(elf.Path, options.PreserveElfAt, true); } } } }