private bool FileReadChosenInterrupt() { int[] xy = GetCurrentCommandLastTwoArguments(); int R1 = Processor.GetRegisterValue("R1").HexToInt(); int R2 = Processor.GetRegisterValue("R2").HexToInt(); char[][] blockFromFile = FileManager.ReadFile(R1, R2); if (blockFromFile == null) { return(false); } bool first = true; for (int i = 0, block = 0; i < R2; block++) { for (int ii = 0; ii < Utility.BLOCK_SIZE || i < R2; ii++, i++) { if (first) { ii = xy[1]; first = false; } int blockAddress = VirtualMemory.GetPager().GetCellRealAddress(((xy[0]) + block) * Utility.BLOCK_SIZE); RealMemory.SetUserMemoryValue(blockAddress + ii, blockFromFile[i]); } } ResetSIRegister(); return(true); }
public Interruptor(Processor processor, VirtualMemory virtualMemory, FileManager fileManager, RealMemory realMemory) { Processor = processor; VirtualMemory = virtualMemory; FileManager = fileManager; RealMemory = realMemory; }
private bool FileWriteChosenInterrupt() { int[] xy = GetCurrentCommandLastTwoArguments(); int R1 = Processor.GetRegisterValue("R1").HexToInt(); int R2 = Processor.GetRegisterValue("R2").HexToInt(); char[][] blockToFile = new char[R2][]; bool first = true; for (int i = 0, block = 0; i < R2; block++) { for (int ii = 0; ii < Utility.BLOCK_SIZE || i < R2; ii++, i++) { if (first) { ii = xy[1]; first = false; } int blockAddress = VirtualMemory.GetPager().GetCellRealAddress(((xy[0]) + block) * Utility.BLOCK_SIZE); blockToFile[i] = RealMemory.GetUserMemoryValue(blockAddress + ii); } } bool result = FileManager.WriteFile(R1, blockToFile); if (!result) { return(false); } ResetSIRegister(); return(true); }
public VirtualMemory(RealMemory memory, Pager pager) { Memory = memory; Pager = pager; }