示例#1
0
        public static void Initialise(Cpu cpu, Instruction[] code = null)
        {
            var ms = new MemoryStream();
            using (var writer = new CodeWriter(ms))
            {
                Array.ForEach(code ?? Instructions, writer.Write);
                writer.Close();

                var codeBlock = cpu.AllocateCodeBlock(cpu.IdleProcess, (uint )ms.Length);
                ms.WriteTo(codeBlock);
            }
        }
示例#2
0
        public static void Initialise(Cpu cpu, Instruction[] code = null)
        {
            var ms = new MemoryStream();

            using (var writer = new CodeWriter(ms))
            {
                Array.ForEach(code ?? Instructions, writer.Write);
                writer.Close();

                var codeBlock = cpu.AllocateCodeBlock(cpu.IdleProcess, (uint )ms.Length);
                ms.WriteTo(codeBlock);
            }
        }
示例#3
0
        public static uint Compile(this Cpu cpu, ProcessContextBlock pcb, IEnumerable <Instruction> instructions)
        {
            var stream = new MemoryStream();

            using (var writer = new CodeWriter(stream))
            {
                foreach (var instruction in instructions)
                {
                    writer.Write(instruction);
                }

                writer.Close();
                using (var ps = cpu.AllocateCodeBlock(pcb, (uint)stream.Length))
                    stream.WriteTo(ps);

                return((uint)stream.Length);
            }
        }