public OpCode(InstructionType type, OpCodeFlag flag, int argument1Type, int argument2Type) { Type = type; Flag = flag; Argument1Type = argument1Type; Argument2Type = argument2Type; }
public static MaskedOpCode SetSource(this MaskedOpCode opCode, OpCodeFlag sourceFlag) { var code = (ushort)opCode; code &= 0xf3ff; var result = code | ((ushort)sourceFlag << 10); return((MaskedOpCode)result); }
public void Enqueue(DeviceId deviceId, ProcessContextBlock pcb, OpCodeFlag flag = OpCodeFlag.Register, uint arg1 = 0) { var blockingProcess = new BlockingProcess { Process = pcb, Flag = flag, Argument = arg1, DeviceId = deviceId }; _deviceQueue[deviceId].Enqueue(blockingProcess); }
public void Input(DeviceId deviceId, OpCodeFlag flag, uint rX) { if (Enum.IsDefined(typeof(DeviceId), deviceId)) { DeviceReadQueue.Enqueue(deviceId, CurrentProcess, flag, rX); CurrentProcess = null; } else { CurrentProcess.Zf = true; } }
public static MaskedOpCode SetDest(this MaskedOpCode opCode, OpCodeFlag destFlag) { if (destFlag == OpCodeFlag.Constant) { throw new InvalidOperationException("Cannot set constant as destination vector"); } var code = (ushort)opCode; code &= 0xfcff; var result = code | ((ushort)destFlag << 8); return((MaskedOpCode )result); }
private string Format(OpCodeFlag opCodeFlag) { switch (opCodeFlag) { case OpCodeFlag.Constant: return Signed ? "+0" : "0x0"; case OpCodeFlag.Register: return Signed ? "+rX" : "rX"; case OpCodeFlag.MemoryAddress: return Signed ? "+[rX]" : "[rX]"; } throw new ArgumentOutOfRangeException(nameof(opCodeFlag)); }
private static void WriteValue(Cpu cpu, OpCodeFlag flag, uint param, uint value) { switch (flag) { case OpCodeFlag.Register: cpu.Registers[param] = value; break; case OpCodeFlag.MemoryAddress: cpu.Write(cpu.Registers[param], value); break; default: throw new ArgumentOutOfRangeException(nameof(flag)); } }
private string Format(OpCodeFlag opCodeFlag) { switch (opCodeFlag) { case OpCodeFlag.Constant: return(Signed ? "+0" : "0x0"); case OpCodeFlag.Register: return(Signed ? "+rX" : "rX"); case OpCodeFlag.MemoryAddress: return(Signed ? "+[rX]" : "[rX]"); } throw new ArgumentOutOfRangeException(nameof(opCodeFlag)); }
private static uint ReadValue(Cpu cpu, OpCodeFlag flag, uint param) { switch (flag) { case OpCodeFlag.Register: return(cpu.Registers[param]); case OpCodeFlag.MemoryAddress: return(cpu.Read(cpu.Registers[param])); case OpCodeFlag.Constant: return(param); default: throw new ArgumentOutOfRangeException(nameof(flag)); } }
private byte Dest(OpCodeFlag flag) { return (byte) flag; }
public static MaskedOpCode SetSource(this MaskedOpCode opCode, OpCodeFlag sourceFlag) { var code = (ushort)opCode; code &= 0xf3ff; var result = code | ((ushort)sourceFlag << 10); return (MaskedOpCode)result; }
public static MaskedOpCode SetDest(this MaskedOpCode opCode, OpCodeFlag destFlag) { if (destFlag == OpCodeFlag.Constant) throw new InvalidOperationException("Cannot set constant as destination vector"); var code = (ushort) opCode; code &= 0xfcff; var result = code | ((ushort)destFlag << 8); return (MaskedOpCode )result; }
private byte Source(OpCodeFlag flag) { return (byte)((byte)flag << 0x2); }
private byte Source(OpCodeFlag flag) { return((byte)((byte)flag << 0x2)); }
private static void ParseArgument([NotNull] IInstructionFetcher fetcher, OpCodeFlag flag, out int argument, out int argumentValue, out int argumentDisplacement, int argumentType, byte modrm) { var mod = (byte)((modrm >> 6) & 7); var reg = (byte)((modrm >> 3) & 7); var rm = (byte)(modrm & 7); switch (argumentType) { case ARG_AX: case ARG_CX: case ARG_DX: case ARG_BX: case ARG_SP: case ARG_BP: case ARG_SI: case ARG_DI: case ARG_IP: case ARG_CS: case ARG_DS: case ARG_ES: case ARG_SS: case ARG_FLAGS: argument = argumentType; argumentValue = ARG_NONE; argumentDisplacement = ARG_NONE; break; case ARG_AL: case ARG_CL: case ARG_DL: case ARG_BL: case ARG_AH: case ARG_CH: case ARG_DH: case ARG_BH: argument = ARG_BYTE_REGISTER; argumentValue = argumentType; argumentDisplacement = ARG_NONE; break; case ARG_1: argument = ARG_CONSTANT; argumentValue = 1; argumentDisplacement = ARG_NONE; break; case ARG_3: argument = ARG_CONSTANT; argumentValue = 3; argumentDisplacement = ARG_NONE; break; case ARG_IB: argument = ARG_CONSTANT; argumentValue = fetcher.FetchU8(); argumentDisplacement = ARG_NONE; if (flag.Has(OpCodeFlag.Signed)) { argumentValue = (sbyte)(byte)argumentValue; } break; case ARG_IW: argument = ARG_CONSTANT; argumentValue = fetcher.FetchU16(); argumentDisplacement = ARG_NONE; break; case ARG_JB: argument = ARG_CONSTANT; argumentValue = (sbyte)fetcher.FetchU8(); argumentDisplacement = ARG_NONE; break; case ARG_JW: argument = ARG_CONSTANT; argumentValue = fetcher.FetchU16(); argumentDisplacement = ARG_NONE; break; case ARG_S: Debug.Assert(reg < 4); argument = reg + ARG_ES; argumentValue = ARG_NONE; argumentDisplacement = ARG_NONE; break; case ARG_GB: argument = ARG_BYTE_REGISTER; argumentValue = ARG_AL + reg; argumentDisplacement = ARG_NONE; break; case ARG_GW: argument = reg; argumentValue = ARG_NONE; argumentDisplacement = ARG_NONE; break; case ARG_OB: case ARG_OW: argument = ARG_MEMORY; argumentValue = fetcher.FetchU16(); argumentDisplacement = ARG_NONE; break; case ARG_A: argument = ARG_FAR_MEMORY; var address = fetcher.FetchU16(); var segment = fetcher.FetchU16(); argumentValue = (int)(((uint)segment << 16) | address); argumentDisplacement = ARG_NONE; break; case ARG_EB: case ARG_EW: case ARG_M: switch (mod) { case 0: if (rm == 6) { argument = ARG_MEMORY; argumentValue = fetcher.FetchU16(); argumentDisplacement = ARG_NONE; } else { argument = ARG_DEREFERENCE; argumentValue = rm; argumentDisplacement = 0; } break; case 1: argument = ARG_DEREFERENCE; argumentValue = rm; argumentDisplacement = (sbyte)fetcher.FetchU8(); break; case 2: argument = ARG_DEREFERENCE; argumentValue = rm; argumentDisplacement = fetcher.FetchU16(); break; case 3: Debug.Assert(argumentType != ARG_M); if (argumentType == ARG_EB) { argument = ARG_BYTE_REGISTER; argumentValue = ARG_AL + rm; } else { argument = rm; argumentValue = ARG_NONE; } argumentDisplacement = ARG_NONE; break; default: throw new NotImplementedException(); } break; case ARG_NONE: argument = ARG_NONE; argumentValue = ARG_NONE; argumentDisplacement = ARG_NONE; break; default: throw new NotImplementedException(); } }
private static uint ReadValue(Cpu cpu, OpCodeFlag flag, uint param) { switch (flag) { case OpCodeFlag.Register: return cpu.Registers[param]; case OpCodeFlag.MemoryAddress: return cpu.Read(cpu.Registers[param]); case OpCodeFlag.Constant: return param; default: throw new ArgumentOutOfRangeException(nameof(flag)); } }
private byte Dest(OpCodeFlag flag) { return((byte)flag); }
public void Input(DeviceId deviceId, OpCodeFlag flag, uint rX) { if (Enum.IsDefined(typeof (DeviceId), deviceId)) { DeviceReadQueue.Enqueue(deviceId, CurrentProcess, flag, rX); CurrentProcess = null; } else { CurrentProcess.Zf = true; } }
private byte Flags(OpCodeFlag dest, OpCodeFlag source) { return (byte) (((byte) source << 0x2) | (byte) dest); }
private byte Flags(OpCodeFlag dest, OpCodeFlag source) { return((byte)(((byte)source << 0x2) | (byte)dest)); }