/// <summary> /// Decodes the operations at the specific address. /// </summary> /// <param name="address">The address.</param> /// <returns></returns> private IEnumerable <Operation> DecodeOperations(ushort address) { _halt = _stop = false; _timer.Reset(); _index = _indexRegisterOperands[IndexRegister.HL]; _prefetch.ReBuildCache(address); while (true) { // Reset _operand1 = Operand.None; _operand2 = Operand.None; _flagTest = FlagTest.None; _opCodeMeta = OpCodeMeta.None; _decodeMeta = DecodeMeta.None; _byteLiteral = 0x00; _wordLiteral = 0x0000; _displacement = 0x00; var opCode = DecodeNextOpCode(); if (!opCode.HasValue) { continue; } if (_decodeMeta.HasFlag(DecodeMeta.Displacement)) { _displacement = _prefetch.NextByte(); } if (_decodeMeta.HasFlag(DecodeMeta.ByteLiteral)) { _byteLiteral = _prefetch.NextByte(); } if (_decodeMeta.HasFlag(DecodeMeta.WordLiteral)) { _wordLiteral = _prefetch.NextWord(); } yield return(new Operation(address, opCode.Value, _operand1, _operand2, _flagTest, _opCodeMeta, _byteLiteral, _wordLiteral, (sbyte)_displacement)); if (_decodeMeta.HasFlag(DecodeMeta.EndBlock)) { yield break; } _index = _indexRegisterOperands[IndexRegister.HL]; address = unchecked ((ushort)(_prefetch.BaseAddress + _prefetch.TotalBytesRead)); } }
private IInstructionTimingsBuilder UpdateDisplacement() { if (!_index.IsDisplaced) { return(_timer.Index(false)); } _decodeMeta |= DecodeMeta.Displacement; return(_timer.Index(true)); }