Ejemplo n.º 1
0
        public static void Msr(ILEmitterCtx context)
        {
            OpCodeSystem64 op = (OpCodeSystem64)context.CurrOp;

            context.EmitLdarg(TranslatedSub.StateArgIdx);
            context.EmitLdintzr(op.Rt);

            string propName;

            switch (GetPackedId(op))
            {
            case 0b11_011_0100_0100_000: propName = nameof(CpuThreadState.Fpcr);     break;

            case 0b11_011_0100_0100_001: propName = nameof(CpuThreadState.Fpsr);     break;

            case 0b11_011_1101_0000_010: propName = nameof(CpuThreadState.TpidrEl0); break;

            default: throw new NotImplementedException($"Unknown MSR at {op.Position:x16}");
            }

            PropertyInfo propInfo = typeof(CpuThreadState).GetProperty(propName);

            if (propInfo.PropertyType != typeof(long) &&
                propInfo.PropertyType != typeof(ulong))
            {
                context.Emit(OpCodes.Conv_U4);
            }

            context.EmitCallPropSet(typeof(CpuThreadState), propName);
        }