public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint address = GetAddress(cpu, instruction.Operand2); int size = instruction.Operand1.Size; StoreValue(cpu, instruction.Operand1, address, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); uint b = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int shift = ((int)b) & 0x1F; if (shift == 0) { return; // no changes } // TODO: for sizes other than 32 Debug.Assert(size == 32); uint u = (a >> 1); shift--; if (cpu.EFLAGS.Carry) { u = u | ((uint)1 << (size - 1)); } if (shift != 0) { u = u >> shift; u = u | (a << (size - shift)); } StoreValue(cpu, instruction.Operand1, (uint)u, size); cpu.EFLAGS.Overflow = cpu.EFLAGS.Carry ^ IsSign(a, size); cpu.EFLAGS.Carry = ((a >> (shift - 1)) & 0x1) == 1; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Size); int size = instruction.Size; StoreFloatValue(cpu, instruction.Operand1, a, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { int a = (int)LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; StoreFloatValue(cpu, instruction.Operand1, (double)a, size); }
public void AddInstruction(LinkerSymbol baseSymbol, long offset, SimInstruction instruction) { lock (mylock2) { instructions.Add(new Tuple <LinkerSymbol, long, SimInstruction>(baseSymbol, offset, instruction)); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (IsSign(cpu.EAX.Value)) cpu.EDX.Value = ~(uint)0; else cpu.EDX.Value = 0; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (cpu.EFLAGS.Sign) { base.Execute(cpu, instruction); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (cpu.EFLAGS.Parity) { cpu.EIP.Value = ResolveBranch(cpu, instruction.Operand1); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand1.Size); int size = instruction.Operand1.Size; StoreFloatValue(cpu, instruction.Operand1, a, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size); uint p = LoadValue(cpu, instruction.Operand2); int size = instruction.Size; float r; if ((p & 0x3) == 0x3) { r = (float)Math.Truncate(a.LowF); } else if ((p & 0x2) == 0x2) { r = (float)Math.Ceiling(a.LowF); } else if ((p & 0x1) == 0x1) { r = (float)Math.Floor(a.LowF); } else { r = (float)Math.Round(a.LowF); } StoreFloatValue(cpu, instruction.Operand1, r, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (cpu.EFLAGS.Sign != cpu.EFLAGS.Overflow) { cpu.EIP.Value = ResolveBranch(cpu, instruction.Operand1); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (!cpu.EFLAGS.Zero) { StoreValue(cpu, instruction.Operand1, 1, 8); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { double a = LoadFloatValue(cpu, instruction.Operand1); double b = LoadFloatValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; if (double.IsNaN(a) || double.IsNaN(b)) { cpu.EFLAGS.Zero = true; cpu.EFLAGS.Parity = true; cpu.EFLAGS.Carry = true; } else if (a == b) { cpu.EFLAGS.Zero = true; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = false; } else if (a > b) { cpu.EFLAGS.Zero = false; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = false; } else { cpu.EFLAGS.Zero = false; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = true; } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); uint b = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int shift = ((int)b) & 0x1F; if (shift == 0) { return; // no changes } bool sign = IsSign(a, size); uint u = a >> shift; if (sign) { uint m = (uint.MaxValue << 32 - shift); u = u | m; } StoreValue(cpu, instruction.Operand1, u, size); UpdateFlags(cpu, size, u, u, true, true, false, false, false); cpu.EFLAGS.Overflow = (shift != 1); cpu.EFLAGS.Carry = ((a >> (shift - 1)) & 0x1) == 1; cpu.EFLAGS.Sign = sign; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); uint b = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int shift = ((int)b) & 0x1F; if (shift == 0) return; // no changes bool sign = IsSign(a, size); uint u = a >> shift; if (sign) { uint m = (uint.MaxValue << (int)(32 - shift)); u = u | m; } StoreValue(cpu, instruction.Operand1, (uint)u, size); UpdateFlags(cpu, size, (long)u, u, true, true, false, false, false); cpu.EFLAGS.Overflow = (shift != 1); cpu.EFLAGS.Carry = ((a >> (shift - 1)) & 0x1) == 1; cpu.EFLAGS.Sign = sign; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (!cpu.EFLAGS.Parity) { cpu.EIP.Value = ResolveBranch(cpu, instruction.Operand1); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); uint b = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int shift = ((int)b) & 0x1F; if (shift == 0) return; // no changes uint u = a << shift; bool sign = IsSign(a, size); //if (cpu.FLAGS.Carry) //{ // u = u | 0x1; //} StoreValue(cpu, instruction.Operand1, u, size); UpdateFlags(cpu, size, u, u, true, true, true, false, false); cpu.EFLAGS.Overflow = sign ^ IsSign(u, size); cpu.EFLAGS.Carry = sign; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (!cpu.EFLAGS.Carry && !cpu.EFLAGS.Zero) { base.Execute(cpu, instruction); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (cpu.EFLAGS.Carry || cpu.EFLAGS.Zero) { cpu.EIP.Value = ResolveBranch(cpu, instruction.Operand1); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (!cpu.EFLAGS.Carry && !cpu.EFLAGS.Zero) { cpu.EIP.Value = ResolveBranch(cpu, instruction.Operand1); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); uint b = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int shift = ((int)b) & 0x1F; if (shift == 0) { return; // no changes } uint u = a << shift; bool sign = IsSign(a, size); //if (cpu.FLAGS.Carry) //{ // u = u | 0x1; //} StoreValue(cpu, instruction.Operand1, u, size); UpdateFlags(cpu, size, u, u, true, true, true, false, false); cpu.EFLAGS.Overflow = sign ^ IsSign(u, size); cpu.EFLAGS.Carry = sign; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; StoreValue(cpu, instruction.Operand1, a, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (cpu.EFLAGS.Sign != cpu.EFLAGS.Overflow) { StoreValue(cpu, instruction.Operand1, 1, 8); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { int a = (int)LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; StoreFloatValue(cpu, instruction.Operand1, (float)a, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var r = LoadFloatValue(cpu, instruction.Operand1, instruction.Operand1.Size); int size = instruction.Operand1.Size; cpu.ST0.Value = r; }
public void AddInstruction(LinkerSymbol baseSymbol, long offset, SimInstruction instruction) { lock (mylock2) { instructions.Add(new Tuple<LinkerSymbol, long, SimInstruction>(baseSymbol, offset, instruction)); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (cpu.EFLAGS.Zero || cpu.EFLAGS.Sign != cpu.EFLAGS.Overflow) { cpu.EIP.Value = ResolveBranch(cpu, instruction.Operand1); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (!cpu.EFLAGS.Zero && cpu.EFLAGS.Sign != cpu.EFLAGS.Overflow) { base.Execute(cpu, instruction); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size).LowF; var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size).LowF; int size = instruction.Size; if (float.IsNaN(a) || float.IsNaN(b)) { cpu.EFLAGS.Zero = true; cpu.EFLAGS.Parity = true; cpu.EFLAGS.Carry = true; } else if (a == b) { cpu.EFLAGS.Zero = true; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = false; } else if (a > b) { cpu.EFLAGS.Zero = false; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = false; } else { cpu.EFLAGS.Zero = false; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = true; } cpu.EFLAGS.Overflow = false; cpu.EFLAGS.Adjust = false; cpu.EFLAGS.Sign = false; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); uint b = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int shift = ((int)b) & 0x1F; if (shift == 0) return; // no changes // TODO: for sizes other than 32 Debug.Assert(size == 32); uint u = (a << 1); if (cpu.EFLAGS.Carry) u = u | 0x1; shift--; u = u << shift; u = u | (a >> (size - shift)); StoreValue(cpu, instruction.Operand1, (uint)u, size); cpu.EFLAGS.Overflow = cpu.EFLAGS.Carry ^ IsSign(a, size); cpu.EFLAGS.Carry = ((a >> (size - shift)) & 0x1) == 1; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size).Low; var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size).Low; int size = instruction.Size; if (double.IsNaN(a) || double.IsNaN(b)) { cpu.EFLAGS.Zero = true; cpu.EFLAGS.Parity = true; cpu.EFLAGS.Carry = true; } else if (a == b) { cpu.EFLAGS.Zero = true; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = false; } else if (a > b) { cpu.EFLAGS.Zero = false; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = false; } else { cpu.EFLAGS.Zero = false; cpu.EFLAGS.Parity = false; cpu.EFLAGS.Carry = true; } cpu.EFLAGS.Overflow = false; cpu.EFLAGS.Adjust = false; cpu.EFLAGS.Sign = false; }
public override void Execute(SimCPU cpu, SimInstruction instruction) { var x86 = cpu as CPUx86; x86.EIP.Value = x86.EIP.Value + instruction.OpcodeSize; Execute(x86, instruction); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand2.Size); int size = instruction.Operand1.Size; uint r = (uint)a.LowF; StoreValue(cpu, instruction.Operand1, r, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { int size = 32; cpu.EFLAGS.Value = Read(cpu, cpu.ESP.Value, size); cpu.ESP.Value = (uint)(cpu.ESP.Value + (size / 8)); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { int size = 32; uint value = Read(cpu, cpu.ESP.Value, size); cpu.ESP.Value = (uint)(cpu.ESP.Value + (size / 8)); cpu.EIP.Value = value; }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; int s = SignExtend(a, instruction.Operand2.Size, size); StoreValue(cpu, instruction.Operand1, (uint)s, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { int size = instruction.Operand1.Size; uint value = Read(cpu, cpu.ESP.Value, size); (instruction.Operand1.Register as GeneralPurposeRegister).Value = value; cpu.ESP.Value = (uint)(cpu.ESP.Value + (size / 8)); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { uint a = LoadValue(cpu, instruction.Operand1); int size = instruction.Operand1.Size; Write(cpu, (uint)(cpu.ESP.Value - (size / 8)), a, size); cpu.ESP.Value = (uint)(cpu.ESP.Value - (size / 8)); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand2, instruction.Operand2.Size); int size = instruction.Operand1.Size; uint r = (uint)a.Low; StoreValue(cpu, instruction.Operand1, r, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (instruction.Operand1 == null) return; uint v1 = LoadValue(cpu, instruction.Operand1); cpu.EIP.Value = (uint)(cpu.EIP.Value + (int)v1); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size); var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size); int size = instruction.Size; double r = a.Low + b.Low; StoreFloatValue(cpu, instruction.Operand1, r, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { double a = LoadFloatValue(cpu, instruction.Operand1); double b = LoadFloatValue(cpu, instruction.Operand2); int size = instruction.Operand1.Size; double r = a - b; StoreFloatValue(cpu, instruction.Operand1, r, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { int size = instruction.Operand1.Size; uint r = cpu.EFLAGS.Value & 0x00FCFFFF; Write(cpu, cpu.ESP.Value, r, size); cpu.ESP.Value = (uint)(cpu.ESP.Value - (size / 8)); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size); var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size); int size = instruction.Size; float r = a.LowF + b.LowF; StoreFloatValue(cpu, instruction.Operand1, r, size); }
/// <summary> /// Sets the Operand value to 1 if the condition is met, otherwise set to 0. /// </summary> /// <param name="cpu"></param> /// <param name="instruction"></param> /// <param name="conditionMet">Boolean indicating if the condition was met</param> public void SetValue(CPUx86 cpu, SimInstruction instruction, bool conditionMet) { if (conditionMet) { StoreValue(cpu, instruction.Operand1, 1, 8); } else { StoreValue(cpu, instruction.Operand1, 0, 8); } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { // Pop Order: EIP, CS, FLAGS int size = 32; cpu.EIP.Value = Read(cpu, cpu.ESP.Value - (8 * 1), size); // Skip CS cpu.EFLAGS.Value = Read(cpu, cpu.ESP.Value - (8 * 3), size); cpu.ESP.Value = (uint)(cpu.ESP.Value + (size * 3 / 8)); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { var a = LoadFloatValue(cpu, instruction.Operand1, instruction.Size); var b = LoadFloatValue(cpu, instruction.Operand2, instruction.Size); int size = instruction.Size; a.ULow = a.ULow ^ b.ULow; a.UHigh = a.UHigh ^ b.UHigh; StoreFloatValue(cpu, instruction.Operand1, a, size); }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (IsSign(cpu.EAX.Value)) { cpu.EDX.Value = ~(uint)0; } else { cpu.EDX.Value = 0; } }
public override void Execute(CPUx86 cpu, SimInstruction instruction) { if (instruction.Operand1 == null) { return; } uint v1 = LoadValue(cpu, instruction.Operand1); cpu.EIP.Value = (uint)(cpu.EIP.Value + (int)v1); }