public Core(int _id, Processor prnt) { _coreId = _id; parent = prnt; instructionsCache = new InstructionCache(4); dataCache = new DataCache(4); }
protected SimInstruction GetInstruction(ulong address) { SimInstruction instruction = null; InstructionCache.TryGetValue(address, out instruction); return(instruction); }
public ZRoutineTable(Story story, InstructionCache cache = null) { this.story = story; this.cache = cache ?? new InstructionCache(8192); this.routines = new IntegerMap <ZRoutine>(8192); this.sortedAddresses = new List <int>(); Add(story.MainRoutineAddress, "Main"); }
public static ZRoutine Create(int address, byte[] memory, InstructionCache cache = null, string name = null) { var version = memory.ReadByte(0); var startAddress = address; var locals = ReadLocals(ref address, memory, version); var instructions = ReadInstructions(address, memory, cache); return(new ZRoutine(startAddress, instructions, locals, name)); }
private static Instruction[] ReadInstructions(int address, byte[] memory, InstructionCache cache) { var reader = new InstructionReader(address, memory, cache); var instructions = new List <Instruction>(); var lastKnownAddress = address; while (true) { var i = reader.NextInstruction(); instructions.Add(i); if ((i.Opcode.IsReturn || i.Opcode.IsQuit) && reader.Address > lastKnownAddress) { break; } else if (i.Opcode.IsJump) { var jumpOffset = (short)i.Operands[0].Value; var jumpAddress = reader.Address + jumpOffset - 2; if (jumpAddress > lastKnownAddress) { lastKnownAddress = jumpAddress; } if (reader.Address > lastKnownAddress) { break; } } else if (i.HasBranch && i.Branch.Kind == BranchKind.Address) { var branchAddress = reader.Address + i.Branch.Offset - 2; if (branchAddress > lastKnownAddress) { lastKnownAddress = branchAddress; } } } return(instructions.ToArray()); }
private Story(byte[] memory) { this.memory = memory; this.version = Header.ReadVersion(memory); this.serialNumber = Header.ReadSerialNumber(memory); this.releaseNumber = Header.ReadReleaseNumber(memory); this.checksum = Header.ReadChecksum(memory); this.actualChecksum = Header.CalculateChecksum(memory); this.routinesOffset = Header.ReadRoutinesOffset(memory); this.stringsOffset = Header.ReadStringsOffset(memory); this.instructionCache = new InstructionCache((memory.Length - Header.ReadStaticMemoryBase(memory)) / 8); this.ztext = new ZText(memory); this.memoryMap = new MemoryMap(memory); this.informData = new InformData(memory, this.memoryMap, ztext); this.objectTable = new ZObjectTable(memory, ztext); this.globalVariablesTable = new GlobalVariablesTable(memory); this.dictionary = new ZDictionary(this, ztext); this.mainRoutineAddress = Header.ReadMainRoutineAddress(memory); RegisterInterpreter(new DefaultInterpreter()); }
public void AddInstruction(ulong address, SimInstruction instruction) { //Debug.Assert(!InstructionCache.ContainsKey(address), instruction.ToString()); InstructionCache.Add(address, instruction); }