public void Dispatch(Cpu8086 cpu, OpCodeManager.Instruction instruction) { switch (instruction.Argument1) { case (int)Register.SP: // 8086 has a bug where it pushes SP after it has been modified // cpu.registers[(int)Register.SP] -= 2; // cpu.WriteU16(SegmentToAddress(cpu.GetRegister(Register.SS), cpu.GetRegister(Register.SP)), cpu.GetRegister(Register.SP)); // break; case (int)Register.AX: case (int)Register.CX: case (int)Register.DX: case (int)Register.BX: case (int)Register.BP: case (int)Register.SI: case (int)Register.DI: case (int)Register.IP: case (int)Register.CS: case (int)Register.DS: case (int)Register.ES: case (int)Register.SS: case unchecked ((int)Register.FLAGS): cpu.Push(cpu.GetRegister((Register)instruction.Argument1)); break; case OpCodeManager.ARG_DEREFERENCE: case OpCodeManager.ARG_MEMORY: var address = InstructionHelper.GetInstructionRealAddress(cpu, instruction.SegmentPrefix, instruction.Argument1, instruction.Argument1Value, instruction.Argument1Displacement); cpu.Push(cpu.ReadU16(address)); break; default: throw new ArgumentOutOfRangeException(); } }
public void Dispatch(Cpu8086 cpu, OpCodeManager.Instruction instruction) { var address = InstructionHelper.GetInstructionValue(cpu, instruction.Flag, instruction.SegmentPrefix, instruction.Argument1, instruction.Argument1Value, instruction.Argument1Displacement); cpu.Push(cpu.GetRegister(Register.IP)); cpu.SetRegister(Register.IP, address); }
public void Dispatch(Cpu8086 cpu, OpCodeManager.Instruction instruction) { cpu.Push(cpu.GetRegister(Register.CS)); cpu.Push(cpu.GetRegister(Register.IP)); new FarJump().Dispatch(cpu, instruction); }
public void Dispatch(Cpu8086 cpu, OpCodeManager.Instruction instruction) { Debug.Assert(instruction.Argument1 == OpCodeManager.ARG_CONSTANT); cpu.Push(cpu.GetRegister(Register.IP)); cpu.SetRegister(Register.IP, (ushort)(cpu.GetRegister(Register.IP) + instruction.Argument1Value)); }