/// <summary> /// Initializes a new instance of the <see cref="Int"/> class. /// </summary> /// <param name="interruptVector">The interrupt vector.</param> public Int(Immediate interruptVector) { #region Contract Contract.Requires <ArgumentNullException>(interruptVector != null); #endregion this.interruptVector = interruptVector; }
/// <summary> /// Initializes a new instance of the <see cref="Imul"/> class. /// </summary> /// <param name="destination">The destination operand.</param> /// <param name="source">The source operand.</param> /// <param name="multiplier">The multiplier.</param> public Imul(RegisterOperand destination, RegisterOperand source, Immediate multiplier) : this(destination, (Operand)source, (Operand)multiplier) { #region Contract Contract.Requires <ArgumentNullException>(multiplier != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="In"/> class. /// </summary> /// <param name="port">The port.</param> public In(Immediate port) : this((Operand)port) { #region Contract Contract.Requires <ArgumentNullException>(port != null); #endregion }
protected override JobHandle StartGeneration(JobHandle dependOn) { if (sourceType == SourceType.FromTheme) { return(deferred ? deferredHandler.ScheduleDeferredJobs(SourceMeshData, Temps, dependOn) : immediateHandler.ScheduleImmediateJobs(SourceMeshData, Temps, dependOn)); } else if (sourceType == SourceType.FromMeshFilters) { MeshCache meshCache; NativeArray <DataInstance> dataInstances; MeshCache.CreateCombinationData(meshFilters, out meshCache, Allocator.TempJob, out dataInstances, Allocator.TempJob); Temps.Add(meshCache); Temps.Add(dataInstances); immediateHandler = new Immediate(dataInstances); return(immediateHandler.ScheduleImmediateJobs(meshCache.MeshData, Temps, dependOn)); } else if (sourceType == SourceType.FromMeshesAndMatrices) { MeshCache meshCache; NativeArray <DataInstance> dataInstances; MeshCache.CreateCombinationData(meshes, matrices, out meshCache, Allocator.TempJob, out dataInstances, Allocator.TempJob); Temps.Add(meshCache); Temps.Add(dataInstances); immediateHandler = new Immediate(dataInstances); return(immediateHandler.ScheduleImmediateJobs(meshCache.MeshData, Temps, dependOn)); } return(dependOn); }
/// <summary> /// Initializes a new instance of the <see cref="Push"/> class. /// </summary> /// <param name="source">The source immediate value.</param> public Push(Immediate source) : this((Operand)source) { #region Contract Contract.Requires <ArgumentNullException>(source != null); #endregion }
public void SetArgument(int i, ulong a) { if (!(i >= 0 && i < Arguments.Length)) { throw new ArgumentException(); } Arguments[i] = new Immediate(a); }
/// <summary> /// Initializes a new instance of the <see cref="ArithmeticInstruction"/> class. /// </summary> /// <param name="destination">The destination memory operand.</param> /// <param name="source">The source immediate operand.</param> protected ArithmeticInstruction(EffectiveAddress destination, Immediate source) : this((IRegisterOrMemoryOperand)destination, (ISourceOperand)source) { #region Contract Contract.Requires <ArgumentNullException>(destination != null); Contract.Requires <ArgumentNullException>(source != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Test"/> class. /// </summary> /// <param name="destination">The destination memory operand.</param> /// <param name="source">The source immediate value.</param> public Test(EffectiveAddress destination, Immediate source) : this((Operand)destination, (Operand)source) { #region Contract Contract.Requires <ArgumentNullException>(destination != null); Contract.Requires <ArgumentNullException>(source != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Bt"/> class. /// </summary> /// <param name="subject">The register operand whose bit is copied.</param> /// <param name="bitindex">The index of the bit to copy.</param> public Bt(RegisterOperand subject, Immediate bitindex) : this((Operand)subject, (Operand)bitindex) { #region Contract Contract.Requires <ArgumentNullException>(subject != null); Contract.Requires <ArgumentNullException>(bitindex != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Rol"/> class. /// </summary> /// <param name="value">The value to change.</param> /// <param name="positions">The number of positions to adjust.</param> public Rol(RegisterOperand value, Immediate positions) : this((Operand)value, (Operand)positions) { #region Contract Contract.Requires <ArgumentNullException>(value != null); Contract.Requires <ArgumentNullException>(positions != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Btc"/> class. /// </summary> /// <param name="subject">The memory operand whose bit is copied and toggled.</param> /// <param name="bitIndex">The index of the bit to copy.</param> public Btc(EffectiveAddress subject, Immediate bitIndex) : this((Operand)subject, (Operand)bitIndex) { #region Contract Contract.Requires <ArgumentNullException>(subject != null); Contract.Requires <ArgumentNullException>(bitIndex != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Cmp"/> class. /// </summary> /// <param name="second">The destination memory operand.</param> /// <param name="first">The source immediate value.</param> public Cmp(EffectiveAddress second, Immediate first) : this((Operand)second, (Operand)first) { #region Contract Contract.Requires <ArgumentNullException>(second != null); Contract.Requires <ArgumentNullException>(first != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Shl"/> class. /// </summary> /// <param name="value">The value to change.</param> /// <param name="positions">The number of positions to adjust.</param> public Shl(EffectiveAddress value, Immediate positions) : this((Operand)value, (Operand)positions) { #region Contract Contract.Requires <ArgumentNullException>(value != null); Contract.Requires <ArgumentNullException>(positions != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Adc"/> class. /// </summary> /// <param name="destination">The destination memory operand.</param> /// <param name="source">The source immediate operand.</param> public Adc(EffectiveAddress destination, Immediate source) : base(destination, source) { #region Contract Contract.Requires <ArgumentNullException>(destination != null); Contract.Requires <ArgumentNullException>(source != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="Or"/> class. /// </summary> /// <param name="destination">The destination register operand.</param> /// <param name="source">The source immediate value.</param> public Or(RegisterOperand destination, Immediate source) : this((Operand)destination, (Operand)source) { #region Contract Contract.Requires <ArgumentNullException>(destination != null); Contract.Requires <ArgumentNullException>(source != null); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="ArithmeticInstruction"/> class. /// </summary> /// <param name="destination">The destination register operand.</param> /// <param name="source">The source immediate operand.</param> protected ArithmeticInstruction(RegisterOperand destination, Immediate source) : this((IRegisterOrMemoryOperand)destination, (ISourceOperand)source) { #region Contract Contract.Requires <ArgumentNullException>(destination != null); Contract.Requires <ArgumentException>(destination.Register.IsGeneralPurposeRegister()); Contract.Requires <ArgumentNullException>(source != null); #endregion }
public void StartAll() { CurrentThread.Start(); Dispatcher.Start(); Immediate.Start(); NewThread.Start(); ThreadPool.Start(); TaskPool.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="Adc"/> class. /// </summary> /// <param name="destination">The destination register operand.</param> /// <param name="source">The source immediate operand.</param> public Adc(RegisterOperand destination, Immediate source) : base(destination, source) { #region Contract Contract.Requires <ArgumentNullException>(destination != null); Contract.Requires <ArgumentException>(destination.Register.IsGeneralPurposeRegister()); Contract.Requires <ArgumentNullException>(source != null); #endregion }
public void Emit(Immediate a) { if (a.type is ImmediateType.Uint64 or ImmediateType.Uint32 or ImmediateType.Uint16 or ImmediateType.Uint8) { Emit(ulong.Parse(a.value)); }
/// <summary> /// Initializes a new instance of the <see cref="Enter"/> class. /// </summary> /// <param name="stackframeSize">The stack frame size.</param> /// <param name="nestingLevel">The nesting level.</param> public Enter(Immediate stackframeSize, Immediate nestingLevel) { #region Contract Contract.Requires <ArgumentNullException>(stackframeSize != null); Contract.Requires <ArgumentNullException>(nestingLevel != null); #endregion this.stackframeSize = stackframeSize; this.nestingLevel = nestingLevel; }
public override void DrawGUI(float Dt) { Immediate.UseShaders(() => { Immediate.TriangleShader = ShaderProgram.Default; Immediate.Texture2D(Engine.WindowSize / 2, CrosshairTex, true); /*Immediate.TriangleShader = MSDF; * Gl.BlendFuncSeparate(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha, BlendingFactor.SrcColor, BlendingFactor.One); * Gl.BlendFuncSeparate(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha, BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);*/ }); }
/* * beaconRegion.NotifyEntryStateOnDisplay = true; * beaconRegion.NotifyOnEntry = true; * beaconRegion.NotifyOnExit = true; * locationmanager.RegionEntered += (object sender, CLRegionEventArgs e) => { * if (e.Region.Identifier == beaconId) { * * var notification = new UILocalNotification () { AlertBody = "The Xamarin beacon is close by!" }; * UIApplication.SharedApplication.CancelAllLocalNotifications(); * UIApplication.SharedApplication.PresentLocationNotificationNow (notification); * } * }; * locationmanager.StartMonitoring (beaconRegion); * * CLBeaconRegion beaconRegionNotifications; */ #endregion public override void DidReceiveMemoryWarning() { base.DidReceiveMemoryWarning(); Unknown.Dispose(); Unknown = null; Near.Dispose(); Near = null; Far.Dispose(); Far = null; Immediate.Dispose(); Immediate = null; }
/// <summary> /// Builds the statements that generate the value of this expression /// </summary> /// <param name="block">Block to which to add the statements</param> /// <param name="expr">Expression to build</param> /// <param name="operand1">First operand</param> /// <param name="operand2">second operand</param> /// <returns></returns> public static Declaration BuildStatements(Block block, Expression expr, Token operand1, Token operand2) { Token opToken = expr.Tokens[0]; var decl = block.CreateTempDeclaration(TypeHelper.GetType(block, operand1)); ValueStatement initialAssign = AssignmentHelper.ParseSingle(block, decl, operand1); block.Statements.Add(initialAssign); var asm = System.Reflection.Assembly.GetExecutingAssembly(); foreach (var type in asm.GetTypes()) { if (type.BaseType == typeof(MathStatement)) { try { IMathOperator mathOp = (IMathOperator)asm.CreateInstance(type.FullName); if (opToken.Equals(mathOp.GetHandledOperator())) { MathStatement mathStatement; Datum datum = Datum.Parse(block, operand2); if (datum == null) { MessageSystem.Instance.ThrowNewError(MessageSystem.ErrorCode.UndeclaredVar); return(null); } if (decl.Type.IndirectionLevels > 0) { Type derefType = decl.Type.Clone() as Type; derefType.Dereference(); var offsetDecl = block.CreateTempDeclaration(new BuiltInType("int")); block.Statements.Add(AssignmentHelper.ParseSingle(block, offsetDecl, operand2)); var imm = new Immediate(new Token(derefType.Size.ToString())); Mult mult = new Mult(offsetDecl, imm); block.Statements.Add(mult); datum = offsetDecl; } mathStatement = Activator.CreateInstance(type, new object[] { decl, datum }) as MathStatement; block.Statements.Add(mathStatement); break; } } catch (MissingMethodException) { } } } return(decl); }
public static void Run(Module module) { var functions = module.GetFunctionEnumerator(); while (functions.MoveNext()) { Block block = functions.Current.Code; var maths = from Statement s in block where s is Add || s is Sub select s; var conds = from Statement s in block where s is ConditionStatement select s; foreach (MathStatement op in maths) { Immediate imm = op.RValue as Immediate; if (imm != null) { Declaration temp = block.CreateTempDeclaration(imm.Type); int offset = block.Statements.IndexOf(op); if (op is Sub) { imm.Negate(); block.Statements.Remove(op); block.Statements.Insert(offset, new Add(temp, imm)); } block.Statements.Insert(offset, new Assignment(temp, imm)); op.RValue = temp; } } foreach (ConditionStatement cond in conds) { if (cond.CondValue is Immediate) { Immediate imm = (Immediate)cond.CondValue; Declaration temp = block.CreateTempDeclaration(imm.Type); int offset = block.Statements.IndexOf(cond); block.Statements.Insert(offset, new Assignment(temp, imm)); cond.CondValue = temp; } } } }
public void Init(NativeArray <DataInstance> instanceArray, TileTheme theme) { sourceType = SourceType.FromTheme; meshFilters = null; meshes = null; matrices = null; deferred = false; immediateHandler = new Immediate(instanceArray); deferredHandler = null; SourceMeshData = theme.TileThemeCache.MeshData; Inited(); }
public void InitDeferred(NativeList <DataInstance> instanceList, TileTheme theme) { sourceType = SourceType.FromTheme; meshFilters = null; meshes = null; matrices = null; deferred = true; deferredHandler = new Deferred(instanceList); immediateHandler = null; SourceMeshData = theme.TileThemeCache.MeshData; Inited(); }
/// <summary> /// Adjusts the operand to reflect the encoding differences /// between variants. /// </summary> /// <param name="operand">The operand to adjust to this descriptor.</param> public void Adjust(Operand operand) { switch (operandType) { case OperandType.RegisterOrMemoryOperand: { RegisterOperand castoperand = operand as RegisterOperand; if (castoperand != null) { // When the operand is a register (and not a memory reference), it needs to be encoded as part of the reg/mem. castoperand.Encoding = RegisterOperandEncoding.ModRm; } break; } case OperandType.RegisterOperand: { RegisterOperand castoperand = operand as RegisterOperand; if (castoperand != null) { // When the operand needs to be added to the opcode, set it as such. castoperand.Encoding = (operandEncoding == OperandEncoding.OpcodeAdd ? RegisterOperandEncoding.AddToOpcode : RegisterOperandEncoding.Default); } break; } case OperandType.Immediate: { Immediate castoperand = operand as Immediate; if (castoperand != null) { castoperand.AsExtraImmediate = (operandEncoding == OperandEncoding.ExtraImmediate); } break; } case OperandType.FixedRegister: case OperandType.MemoryOperand: case OperandType.MemoryOffset: case OperandType.FarPointer: case OperandType.RelativeOffset: case OperandType.None: default: break; } }
public void Init(Mesh[] meshes, Matrix4x4[] matrices) { sourceType = SourceType.FromMeshesAndMatrices; meshFilters = null; this.meshes = meshes; this.matrices = matrices; deferred = false; deferredHandler = null; immediateHandler = null; SourceMeshData = default; Inited(); }
/// <summary> /// Writes an effective address operand. /// </summary> /// <returns>The number of characters written.</returns> private int WriteOperand(Immediate operand, bool writeSize) { #region Contract if (operand == null) { return(0); } #endregion int length = 0; if (writeSize) { switch (operand.RequestedSize) { case DataSize.Bit8: Writer.Write("byte "); length += 5; break; case DataSize.Bit16: Writer.Write("word "); length += 5; break; case DataSize.Bit32: Writer.Write("dword "); length += 6; break; case DataSize.Bit64: Writer.Write("qword "); length += 6; break; case DataSize.None: break; default: throw new LanguageException(ExceptionStrings.UnknownRequestedSize); } } length += WriteExpression(operand.Expression); return(length); }
//public static bool IsLValue() //{ //} public static ValueStatement ParseSingle(Block block, Declaration LValue, Token RValue) { if (Immediate.IsImmediate(RValue) == false) { Declaration valDecl = block.FindDeclaration(RValue.Text); if (valDecl != null && LValue.ConstValue != null) { LValue.ConstValue = new Immediate(LValue.ConstValue.Value); } return(new Move(LValue, valDecl)); } else { Immediate valImm = new Immediate(RValue); LValue.ConstValue = valImm; return(new Assignment(LValue, valImm)); } }
/// <summary> /// Writes an effective address operand. /// </summary> /// <returns>The number of characters written.</returns> private int WriteOperand(Immediate operand, bool writeSize) { #region Contract if (operand == null) return 0; #endregion int length = 0; if (writeSize) { switch (operand.RequestedSize) { case DataSize.Bit8: Writer.Write("byte "); length += 5; break; case DataSize.Bit16: Writer.Write("word "); length += 5; break; case DataSize.Bit32: Writer.Write("dword "); length += 6; break; case DataSize.Bit64: Writer.Write("qword "); length += 6; break; case DataSize.None: break; default: throw new LanguageException(ExceptionStrings.UnknownRequestedSize); } } length += WriteExpression(operand.Expression); return length; }
public static Action call(CPU cpu, Immediate<ushort> o) => () => cpu.Call(o.Target, 3);
public static Action call(CPU cpu, FlagCondition o1, Immediate<ushort> o2) => () => { if (o1.Target) cpu.Call(o2.Target, 3); };