private void frmRegisters_Load(object sender, EventArgs e) { registers.Append <uint16_t>(Register.PC); // Program counter registers.Append <uint16_t>(Register.MAR); // Memory address register registers.Append <uint16_t>(Register.MLR); // Memory length register registers.Append <uint64_t>(Register.MDR); // Memory data register (64-bits) registers.Subdivide(Register.MDR, Register.MDR32); // 32-bit MDR register registers.Subdivide(Register.MDR32, Register.MDR16); // 16-bit MDR register registers.Subdivide(Register.MDR16, Register.MDR8); // 8-bit MDR register registers.Append <Opcode>(Register.CIR); // Current instruction register registers.Append <uint16_t>(Register.IDT); // Interrupt Descriptor Table address registers.Append <uint64_t>(Register.FLAGS); // Flags register registers.Append <uint32_t>(Register.SVM); registers.Append <uint32_t>(Register.EAX); registers.Subdivide(Register.EAX, Register.AX); registers.Subdivide(Register.AX, Register.AL, Register.AH); registers.Append <uint32_t>(Register.EBX); registers.Subdivide(Register.EBX, Register.BX); registers.Subdivide(Register.BX, Register.BL, Register.BH); registers.Append <uint32_t>(Register.ECX); registers.Subdivide(Register.ECX, Register.CX); registers.Subdivide(Register.CX, Register.CL, Register.CH); registers.Append <uint32_t>(Register.EDX); registers.Subdivide(Register.EDX, Register.DX); registers.Subdivide(Register.DX, Register.DL, Register.DH); registers.Append <uint16_t>(Register.ABP); registers.Append <uint16_t>(Register.AEI); registers.Append <uint16_t>(Register.AEL); registers.Append <uint16_t>(Register.AEP); registers.BuildMemory(); //byte[] bin = Assemble(); byte[] bcmos = System.IO.File.ReadAllBytes("cmos.bin"); byte[] bdisk1 = System.IO.File.ReadAllBytes("disk1.bin"); // Build the VM cmosMemory = new Memory2(bcmos); cmos = new DiskDrive(cmosMemory); disk1Memory = new Memory2(bdisk1); disk1 = new DiskDrive(disk1Memory); sb = new Southbridge(cmos); sb.AddDevice(disk1); keyboard = new Keyboard(); sb.AddDevice(keyboard); cpu = new CPU2(); graphics = new MonochromeDisplayAdapter(); nb = new Northbridge(cpu, sb, new Memory2(64 * 1024), graphics); clock = new ThreadedClock(nb); nb.Clock = clock; vm = new VirtualMachine(cpu, clock, nb, sb); byte[] state = vm.GetRegisters(); registers.LoadState(state); //graphics.Write(0, Encoding.ASCII.GetBytes("Hello World!")); UpdateList(); }
public CPU1() { stack = new Stack <IDataType>(); opcodes = new Dictionary <Opcodes, Delegate>(); registers = new Registers <Register>(); registers.Append <uint16_t>(Register.PC); // Program counter registers.Append <uint16_t>(Register.MAR); // Memory address register registers.Append <uint16_t>(Register.MLR); // Memory length register registers.Append <uint64_t>(Register.MDR); // Memory data register (64-bits) registers.Subdivide(Register.MDR, Register.MDR32); // 32-bit MDR register registers.Subdivide(Register.MDR32, Register.MDR16); // 16-bit MDR register registers.Subdivide(Register.MDR16, Register.MDR8); // 8-bit MDR register registers.Append <Opcode>(Register.CIR); // Current instruction register registers.Append <uint16_t>(Register.IDT); // Interrupt Descriptor Table address registers.Append <uint64_t>(Register.FLAGS); // Flags register registers.Append <uint32_t>(Register.SVM); // Shared Video Memory address registers.Append <uint32_t>(Register.EAX); registers.Subdivide(Register.EAX, Register.AX); registers.Subdivide(Register.AX, Register.AL, Register.AH); registers.Append <uint32_t>(Register.EBX); registers.Subdivide(Register.EBX, Register.BX); registers.Subdivide(Register.BX, Register.BL, Register.BH); registers.Append <uint32_t>(Register.ECX); registers.Subdivide(Register.ECX, Register.CX); registers.Subdivide(Register.CX, Register.CL, Register.CH); registers.Append <uint32_t>(Register.EDX); registers.Subdivide(Register.EDX, Register.DX); registers.Subdivide(Register.DX, Register.DL, Register.DH); registers.Append <uint16_t>(Register.ABP); registers.Append <uint16_t>(Register.AEI); registers.Append <uint16_t>(Register.AEL); registers.Append <uint16_t>(Register.AEP); registers.BuildMemory(); SetupOpCodes(); registers.Write <uint64_t>(Register.FLAGS, new uint64_t((ulong)CPUFlags.Empty)); }