/// <summary> /// Constructor /// </summary> /// <param name="register">Register</param> /// <param name="access">Register access</param> public UsedRegister(Register register, OpAccess access) { Debug.Assert((uint)register <= byte.MaxValue); this.register = (byte)register; Debug.Assert((uint)access <= byte.MaxValue); this.access = (byte)access; }
public bool TryGetOpAccess(int operand, out OpAccess access) { int instructionOperand; switch (operand) { case 0: instructionOperand = Op0Index; break; case 1: instructionOperand = Op1Index; break; case 2: instructionOperand = Op2Index; break; case 3: instructionOperand = Op3Index; break; case 4: instructionOperand = Op4Index; break; default: Debug.Assert(Op0Kind == InstrOpKind.DeclareByte || Op0Kind == InstrOpKind.DeclareWord || Op0Kind == InstrOpKind.DeclareDword || Op0Kind == InstrOpKind.DeclareQword); instructionOperand = -1; break; } if (instructionOperand < InstrInfo.OpAccess_INVALID) { access = (OpAccess)(-instructionOperand - 2); return(true); } access = OpAccess.None; return(false); }
public bool TryGetOpAccess(int operand, out OpAccess access) { int instructionOperand; switch (operand) { case 0: instructionOperand = Op0Index; break; case 1: instructionOperand = Op1Index; break; case 2: instructionOperand = Op2Index; break; case 3: instructionOperand = Op3Index; break; case 4: instructionOperand = Op4Index; break; default: throw new ArgumentOutOfRangeException(nameof(operand)); } if (instructionOperand < InstrInfo.OpAccess_INVALID) { access = (OpAccess)(-instructionOperand - 2); return(true); } access = OpAccess.None; return(false); }
static void AddReadReg(List <ImplAccStatement> extra, ImplAccRegister?reg, OpAccess opAccess, bool isMemOpSegRead) { if (reg is ImplAccRegister reg2) { switch (reg2.Kind) { case ImplAccRegisterKind.Register: case ImplAccRegisterKind.SegmentDefaultDS: case ImplAccRegisterKind.a_rDI: extra.Add(new RegisterImplAccStatement(opAccess, reg2, isMemOpSegRead)); break; case ImplAccRegisterKind.Op0: case ImplAccRegisterKind.Op1: case ImplAccRegisterKind.Op2: case ImplAccRegisterKind.Op3: case ImplAccRegisterKind.Op4: // Added automatically by the runtime code break; default: throw new InvalidOperationException(); } } }
public RegisterImplAccStatement(OpAccess access, ImplAccRegister register, bool isMemOpSegRead) { IsMemOpSegRead = register.Kind == ImplAccRegisterKind.SegmentDefaultDS; if (isMemOpSegRead) { if (register.Kind == ImplAccRegisterKind.Register) { switch ((Register)register.Register !.Value) {
public Source_GPIO( rfid.Constants.GpioPin nativePin, OpState state ) : base() { this.nativePin = nativePin; this.access = OpAccess.SET; this.state = state; this.status = OpResult.FAILURE; }
public Source_GPIO ( rfid.Constants.GpioPin nativePin, OpState state ) : base( ) { this.nativePin = nativePin; this.access = OpAccess.SET; this.state = state; this.status = OpResult.FAILURE; }
public RegisterRangeImplAccStatement(OpAccess access, EnumValue registerFirst, EnumValue registerLast) { Access = access; RegisterFirst = registerFirst; RegisterLast = registerLast; }
/// <summary> /// Constructor /// </summary> /// <param name="segReg">Effective segment register or <see cref="Register.None"/> if the segment register is ignored</param> /// <param name="baseReg">Base register</param> /// <param name="indexReg">Index register</param> /// <param name="scale">1, 2, 4 or 8</param> /// <param name="displ">Displacement</param> /// <param name="memorySize">Memory size</param> /// <param name="access">Access</param> public UsedMemory(Register segReg, Register baseReg, Register indexReg, int scale, long displ, MemorySize memorySize, OpAccess access) { this.displ = (ulong)displ; Debug.Assert((uint)segReg <= byte.MaxValue); this.segReg = (byte)segReg; Debug.Assert((uint)baseReg <= byte.MaxValue); this.baseReg = (byte)baseReg; Debug.Assert((uint)indexReg <= byte.MaxValue); this.indexReg = (byte)indexReg; Debug.Assert((uint)memorySize <= byte.MaxValue); this.memorySize = (byte)memorySize; Debug.Assert(scale == 1 || scale == 2 || scale == 4 || scale == 8); this.scale = (byte)scale; Debug.Assert((uint)access <= byte.MaxValue); this.access = (byte)access; addressSize = (byte)CodeSize.Unknown; vsibSize = 0; }
/// <summary> /// Constructor /// </summary> /// <param name="segReg">Effective segment register or <see cref="Register.None"/> if the segment register is ignored</param> /// <param name="baseReg">Base register</param> /// <param name="indexReg">Index register</param> /// <param name="scale">1, 2, 4 or 8</param> /// <param name="displ">Displacement</param> /// <param name="memorySize">Memory size</param> /// <param name="access">Access</param> /// <param name="addressSize">Address size</param> /// <param name="vsibSize">VSIB size (<c>0</c>, <c>4</c> or <c>8</c>)</param> public UsedMemory(Register segReg, Register baseReg, Register indexReg, int scale, ulong displ, MemorySize memorySize, OpAccess access, CodeSize addressSize, int vsibSize) { this.displ = displ; Debug.Assert((uint)segReg <= byte.MaxValue); this.segReg = (byte)segReg; Debug.Assert((uint)baseReg <= byte.MaxValue); this.baseReg = (byte)baseReg; Debug.Assert((uint)indexReg <= byte.MaxValue); this.indexReg = (byte)indexReg; Debug.Assert((uint)memorySize <= byte.MaxValue); this.memorySize = (byte)memorySize; Debug.Assert(scale == 1 || scale == 2 || scale == 4 || scale == 8); this.scale = (byte)scale; Debug.Assert((uint)access <= byte.MaxValue); this.access = (byte)access; Debug.Assert((uint)addressSize <= byte.MaxValue); this.addressSize = (byte)addressSize; Debug.Assert(vsibSize == 0 || vsibSize == 4 || vsibSize == 8); this.vsibSize = (byte)vsibSize; }
/// <summary> /// Constructor /// </summary> /// <param name="register">Register</param> /// <param name="access">Register access</param> public UsedRegister(Register register, OpAccess access) { this.register = register; this.access = access; }
/// <summary> /// Returns the operand access but only if it's an operand added by the formatter. If it's an /// operand that is part of <see cref="Instruction"/>, you should call eg. /// <see cref="Instruction.GetInfo()"/> or <see cref="InstructionInfoFactory.GetInfo(ref Instruction)"/>. /// </summary> /// <param name="instruction">Instruction</param> /// <param name="operand">Operand number, 0-based. This is a formatter operand and isn't necessarily the same as an instruction operand. /// See <see cref="GetOperandCount(ref Instruction)"/></param> /// <param name="access">Updated with operand access if successful</param> /// <returns></returns> public abstract bool TryGetOpAccess(ref Instruction instruction, int operand, out OpAccess access);
public ActionResult PostAccessData() { int parentId = DoRequest.GetFormInt("parentId"); int nodeId = DoRequest.GetFormInt("nodeId"); string name = DoRequest.GetFormString("name").Trim(); int sort = DoRequest.GetFormInt("sort"); string desc = DoRequest.GetFormString("desc"); #region 验证 if (string.IsNullOrEmpty(name)) { return(Json(new { error = true, message = "名称不能为空" })); } #endregion List <AccessInfo> accesslist = new List <AccessInfo>(); var reslist = QueryAccessList.Do(); if (reslist != null && reslist.Body != null && reslist.Body.access_list != null) { accesslist = reslist.Body.access_list; } AccessInfo pNode = accesslist.FindLast(delegate(AccessInfo item) { return(item.access_id == parentId); }); AccessInfo cNode = accesslist.FindLast(delegate(AccessInfo item) { return(item.access_id == nodeId); }); if (pNode == null) { pNode = new AccessInfo(); } if (cNode == null) { cNode = new AccessInfo(); } #region 初始化参数 if (pNode.access_id == 0 && cNode.access_id == 0) { cNode.parent_id = 0; } else { cNode.parent_id = pNode.access_id; } cNode.access_name = name; cNode.sort_no = sort; cNode.access_desc = desc; #endregion int returnValue = -1; bool isAdd = false; if (cNode.access_id == 0) { //新增 cNode.access_id = 0; isAdd = true; var resResp = OpAccess.Do(cNode); if (resResp != null && resResp.Header != null && resResp.Header.Result != null && resResp.Header.Result.Code != null) { returnValue = Utils.StrToInt(resResp.Header.Result.Code, -1); } } else { //更新 var resResp = OpAccess.Do(cNode); if (resResp != null && resResp.Header != null && resResp.Header.Result != null && resResp.Header.Result.Code != null) { returnValue = Utils.StrToInt(resResp.Header.Result.Code, -1); } } bool isError = true; string message = "操作失败"; if (returnValue == 0) { isError = false; message = "操作成功"; } return(Json(new { error = isError, message = message, isadd = isAdd })); }
public void Copy( Source_GPIO from ) { this.nativePin = from.nativePin; this.access = from.access; this.state = from.state; this.status = from.status; }
static bool AddRegisters(Dictionary <string, Register> toRegister, string value, OpAccess access, InstructionInfoTestCase testCase) { foreach (var tmp in value.Split(semicolonSeparator, StringSplitOptions.RemoveEmptyEntries)) { var regString = tmp.Trim(); if (!toRegister.TryGetValue(regString, out var reg)) { return(false); } if (testCase.Encoding != EncodingKind.Legacy && testCase.Encoding != EncodingKind.D3NOW) { switch (access) { case OpAccess.None: case OpAccess.Read: case OpAccess.NoMemAccess: case OpAccess.CondRead: break; case OpAccess.Write: case OpAccess.CondWrite: case OpAccess.ReadWrite: case OpAccess.ReadCondWrite: if (Register.XMM0 <= reg && reg <= IcedConstants.VMM_last && !regString.StartsWith(MiscInstrInfoTestConstants.VMM_prefix, StringComparison.OrdinalIgnoreCase)) { throw new Exception($"Register {regString} is written ({access}) but {MiscInstrInfoTestConstants.VMM_prefix} pseudo register should be used instead"); } break; default: throw new InvalidOperationException(); } } testCase.UsedRegisters.Add(new UsedRegister(reg, access)); } return(true); }
static bool AddMemory(int bitness, Dictionary <string, Register> toRegister, string value, OpAccess access, InstructionInfoTestCase testCase) { var elems = value.Split(semicolonSeparator); if (elems.Length != 2) { return(false); } var expr = elems[0].Trim(); if (!ToEnumConverter.TryMemorySize(elems[1].Trim(), out var memorySize)) { return(false); } if (!TryParseMemExpr(toRegister, expr, out var segReg, out var baseReg, out var indexReg, out int scale, out ulong displ)) { return(false); } switch (bitness) { case 16: if (!(short.MinValue <= (long)displ && (long)displ <= short.MaxValue) && displ > ushort.MaxValue) { return(false); } displ = (ushort)displ; break; case 32: if (!(int.MinValue <= (long)displ && (long)displ <= int.MaxValue) && displ > uint.MaxValue) { return(false); } displ = (uint)displ; break; case 64: break; default: throw new InvalidOperationException(); } if (access != OpAccess.NoMemAccess) { testCase.UsedMemory.Add(new UsedMemory(segReg, baseReg, indexReg, scale, displ, memorySize, access)); } return(true); }