public LoadProgram ( String fileName, IEnumerable |
||
fileName | String | |
programArguments | IEnumerable |
|
Résultat | void |
public void LoadProgram(String fileName, IEnumerable<String> programArguments)
{
// Load the program into memory.
byte[] programData = File.ReadAllBytes(fileName);
Array.Copy(programData, _memory, programData.Length);
// Load the args into memory.
if (programArguments != null)
{
int argIndex = (64*3)/8;
foreach (var arg in programArguments)
{
long argValue = long.Parse(arg);
byte[] argBinary = BitConverter.GetBytes(argValue);
Array.Copy(argBinary, 0, _memory, argIndex, argBinary.Length);
argIndex += 64 / 8;
}
}
}
MemoryController::LoadProgram ( String fileName ) : void |
static void Main(string[] args) { // Create memory and load the program and arguments (if present). _mem = new MemoryController(); if (args.Length >= 1) { _mem.LoadProgram(args[0], args.Skip(1)); } else if (args.Length == 1) { _mem.LoadProgram(args[0]); } InterruptHandler interruptHandler = new InterruptHandler(_mem); _mappedDevices = new List <IMemoryMappedDevice>(); // Create a memory mapped console device. ConsoleDevice consoleDevice = new ConsoleDevice(_mem, interruptHandler, 1048448, 128); _mappedDevices.Add(consoleDevice); KeyboardDevice keyboardDevice = new KeyboardDevice(_mem, interruptHandler, 1048319, 128); _mappedDevices.Add(keyboardDevice); DisplayDevices(_mem, _mappedDevices, interruptHandler); Console.WriteLine(); Console.WriteLine("Ready. Press enter to begin..."); Console.ReadLine(); Console.Clear(); // Start the keyboard device. keyboardDevice.StartDevice(); _mem.DebugWrite(); // Create the CPU and start it running. _cpu = new CPU(_mem, interruptHandler); _cpu.Run(); Console.ReadLine(); }