private void Disassemble(DisassemblyMode mode, ushort startAddress, ushort length) { if (startAddress > Memory.Size) { throw new InvalidOperationException(String.Format("Start address must be less than the size of system memory ({0}).", Helpers.ToOctal(Memory.Size))); } ushort endAddress = (ushort)Math.Min(Memory.Size, startAddress + length); ushort address = startAddress; while (address < endAddress) { string disassembly = string.Empty; int size = 0; try { switch (mode) { case DisassemblyMode.Processor: size = 1; disassembly = Processor.Disassemble(address); break; case DisassemblyMode.DisplayAuto: disassembly = DisplayProcessor.Disassemble(address, DisplayProcessorMode.Indeterminate, out size); break; case DisassemblyMode.DisplayProcessor: disassembly = DisplayProcessor.Disassemble(address, DisplayProcessorMode.Processor, out size); break; case DisassemblyMode.DisplayIncrement: disassembly = DisplayProcessor.Disassemble(address, DisplayProcessorMode.Increment, out size); break; case DisassemblyMode.DisplayCompact: disassembly = DisplayProcessor.Disassemble(address, DisplayProcessorMode.CompactAddressing, out size); break; } } catch { // this can happen if the data is not a valid instruction disassembly = "<invalid instruction>"; size = 1; } Console.WriteLine("{0}\\{1} {2}", Helpers.ToOctal(address), Helpers.ToOctal(Memory.Fetch(address)), disassembly); address += (ushort)size; } }
public ImlacSystem() { _memory = new Memory(this); _paperTapeReader = new PaperTapeReader(this); _tty = new TTY(this); _keyboard = new Keyboard(this); _clock = new AddressableClock(this); _interruptFacility = new InterruptFacility(this); _displayProcessor = new DisplayProcessor(this); _processor = new Processor(this); // Register IOT devices _processor.RegisterDeviceIOTs(_displayProcessor); _processor.RegisterDeviceIOTs(_paperTapeReader); _processor.RegisterDeviceIOTs(_tty); _processor.RegisterDeviceIOTs(_keyboard); _processor.RegisterDeviceIOTs(_clock); _processor.RegisterDeviceIOTs(_interruptFacility); }