예제 #1
0
        ushort IInstructionFetcher.FetchU16()
        {
            var value = _cpu.ReadU16(InstructionHelper.SegmentToAddress(
                                         _cpu.GetRegister(Register.CS),
                                         (ushort)(_cpu.GetRegister(Register.IP) + _fetched)));

            _fetched += 2;
            return(value);
        }
예제 #2
0
        public static ushort GetInstructionValue(Cpu8086 cpu, OpCodeManager.OpCodeFlag flag, Register segmentPrefix, int instruction, int instructionValue, int instructionDisplacement)
        {
            switch (instruction)
            {
            case (int)Register.AX:
            case (int)Register.CX:
            case (int)Register.DX:
            case (int)Register.BX:
            case (int)Register.SP:
            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:
                return(cpu.GetRegister((Register)instruction));

            case OpCodeManager.ARG_BYTE_REGISTER:
                return(cpu.GetRegisterU8((Register)instructionValue));

            case OpCodeManager.ARG_DEREFERENCE:
            case OpCodeManager.ARG_MEMORY:
                var address = GetInstructionRealAddress(cpu, segmentPrefix, instruction, instructionValue, instructionDisplacement);
                return(flag.Has(OpCodeManager.OpCodeFlag.Size8) ? cpu.ReadU8(address) : cpu.ReadU16(address));

            case OpCodeManager.ARG_CONSTANT:
                return((ushort)instructionValue);

            default:
                throw new NotImplementedException();
            }
        }