public void ReadHighByteOnly(byte channel) { Reset(); mbbsEmuCpuRegisters.AL = (byte)((2 << 4) | (channel << 6)); fakeClock.CurrentTick = 0.25; var expected = (ushort)(int)(ProgrammableIntervalTimer.FREQUENCY * (1.0 - fakeClock.CurrentTick)); var instructions = new Assembler(16); instructions.@out(0x43, al); instructions.@in(al, (byte)(0x40 + channel)); instructions.mov(ah, al); instructions.@in(al, (byte)(0x40 + channel)); instructions.hlt(); CreateCodeSegment(instructions); while (!mbbsEmuCpuRegisters.Halt) { mbbsEmuCpuCore.Tick(); } mbbsEmuCpuRegisters.AL.Should().Be((byte)(expected >> 8)); mbbsEmuCpuRegisters.AH.Should().Be((byte)(expected >> 8)); }
public void ReadLatchedValue(byte channel) { Reset(); mbbsEmuCpuRegisters.AL = (byte)((0 << 4) | (channel << 6)); // latched fakeClock.CurrentTick = 0.25; var expected = (ushort)(int)(ProgrammableIntervalTimer.FREQUENCY * (1.0 - fakeClock.CurrentTick)); var instructions = new Assembler(16); instructions.@out(0x43, al); instructions.@in(al, (byte)(0x40 + channel)); instructions.mov(ah, al); instructions.@in(al, (byte)(0x40 + channel)); instructions.xchg(ah, al); instructions.hlt(); CreateCodeSegment(instructions); // program the PIT - sets the latched value mbbsEmuCpuCore.Tick(); // reset clock to another value to verify latched value is read // and not this new value fakeClock.CurrentTick = 0; while (!mbbsEmuCpuRegisters.Halt) { mbbsEmuCpuCore.Tick(); } mbbsEmuCpuRegisters.AL.Should().Be((byte)expected); mbbsEmuCpuRegisters.AH.Should().Be((byte)(expected >> 8)); }