상속: MonoBehaviour
예제 #1
0
 public void EmitMOV(Register regDst, int imm32)
 {
     AddrMode rexAddrMode = new AddrMode(regDst, null, 0, 0, AddrModeSize.Int32);
     EmitRexPrefix(regDst, ref rexAddrMode);
     Builder.EmitByte((byte)(0xB8 | ((int)regDst & 0x07)));
     Builder.EmitInt(imm32);
 }
예제 #2
0
파일: Debugger.cs 프로젝트: claassen/RIVM
 private void updateRegisterState(TextBox txt, Register register)
 {
     txt.Invoke((MethodInvoker)(() =>
     {
         txt.Text = _vm.cpu.Registers[register].ToString();
     }));
 }
 /// <summary>
 /// Pushes the current value of our programmCounter to the operationStack and sets programmCounter to INTERRUPT_VECTOR_ADDRESS
 /// </summary>
 public void triggerInterrupt(Data.OperationStack operationStack, Register.ProgramCounter programCounter)
 {
     operationStack.push(programCounter.value);
     programCounter.value = Register.RegisterConstants.INTERRUPT_VECTOR_ADDRESS;
     registerFileMap.clearBit(Register.RegisterConstants.INTCON_ADDRESS, Register.RegisterConstants.INTCON_GIE_MASK);
     pic.setInterruptIsNext(false);
 }
예제 #4
0
 public void ValueBackingTest1()
 {
     var backing = new MockRegisterValueBacking();
     var reg = new Register(RegisterName.Unnamed, backing);
     reg.RegisterValue = RegisterValue.OfString("foo", OperationKind.CharacterWise);
     Assert.AreEqual("foo", backing.RegisterValue.StringValue);
 }
예제 #5
0
        private void RegisterBtn_Click(object sender, RoutedEventArgs e)
        {
            clearErrorText();

            if (validateFields())
            {
                if (PasswordTxt.Password.Equals(ConfirmPasswordTxt.Password))
                {
                    Register regis = new Register() { username = UsernameTxt.Text, cardNumber = CardNumberTxt.Text, isPublic = (PublicSwitch.IsOn + "").ToLower(), name = NameTxt.Text, password = PasswordTxt.Password, phoneNumber = PhoneTxt.Text };
                    RequestHandle handler = new RequestHandle();
                    LoginResponse res = Task.Run(() => handler.register(regis)).Result;
                    switch (res.user.responseStatus.status)
                    {
                        case "INVALID_REGISTRATION_USERNAME":
                            UsernameErrorTxt.Text = "Username is already in use.";
                            break;
                        case "INVALID_REGISTRATION_CARDNUMBER":
                            CardNumberErrorTxt.Text = "Card number is  invalid or in use.";
                            break;
                        case "INVALID_REGISTRATION_PHONE":
                            PhoneErrorTxt.Text = "Phone is already in use.";
                            break;
                        case "SUCCESS":
                            this.Frame.Navigate(typeof(DashboardPage), res.user);
                            break;
                    }
                }
                else
                {
                    PasswordErrorTxt.Text = "Passwords entered do not match.";
                }
            }
        }
        public static void AddModuloQFTPhi(this QuantumComputer comp, ulong a, ulong N, RegisterRef ctrl, Register b, params RegisterRef[] controls)
        {
            if (comp.Group)
            {
                object[] parameters = new object[] { comp, a, N, ctrl, b, controls };
                comp.AddParametricGate("AddModuloQFTPhi", parameters);
                return;
            }
            else
            {
                comp.Group = true;
            }

            comp.AddQFTPhi(a, b, controls);
            comp.InverseAddQFTPhi(N, b);

            comp.InverseQFT(b);
            comp.CNot(ctrl, b[b.Width - 1]);
            comp.QFT(b);

            comp.AddQFTPhi(N, b, ctrl);
            comp.InverseAddQFTPhi(a, b, controls);

            comp.InverseQFT(b);
            comp.SigmaX(b[b.Width - 1]);
            comp.CNot(ctrl, b[b.Width - 1]);
            comp.SigmaX(b[b.Width - 1]);
            comp.QFT(b);

            comp.AddQFTPhi(a, b, controls);
        }
예제 #7
0
 public void Test_Registered()
 {
     Register r = new Register(doc);
     r.Registered = true;
     Assert.AreEqual("<query xmlns=\"jabber:iq:register\"><registered /></query>", r.ToString());
     Assert.IsTrue(r.Registered);
 }
예제 #8
0
 public void RegisterTaskPanes(Register register)
 {
     myAddinTaskPane = register(() =>
         {
             var button = new System.Windows.Controls.Button
             {
                 Content = "Insert Quote"
             };
             button.Click += InsertQuote;
             var host = new WpfPanelHost
             {
                 Child = new UserControl
                 {
                     Content = new StackPanel
                     {
                         Children =
                         {
                             button
                         }
                     }
                 }
             };
             return host;
         }, "Quotes!");
     myAddinTaskPane.Visible = true;
     myAddinTaskPane.VisibleChanged += TaskPaneVisibleChanged;
     TaskPaneVisibleChanged(this, EventArgs.Empty);
 }
예제 #9
0
        public TargetRegisterMap(TargetOS os)
        {
            switch (os)
            {
                case TargetOS.Windows:
                    Arg0 = Register.RCX;
                    Arg1 = Register.RDX;
                    Arg2 = Register.R8;
                    Arg3 = Register.R9;
                    Result = Register.RAX;
                    break;

                case TargetOS.Linux:
                case TargetOS.OSX:
                case TargetOS.FreeBSD:
                    Arg0 = Register.RDI;
                    Arg1 = Register.RSI;
                    Arg2 = Register.RDX;
                    Arg3 = Register.RCX;
                    Result = Register.RAX;
                    break;
                default:
                    throw new NotImplementedException();
            }
        }
예제 #10
0
 public void CanSetTheValueOfARegister()
 {
     var register = new Register(8);
       const int expectedValue = 42;
       register.SetValue(expectedValue);
       Assert.That(register.GetValue(), Is.EqualTo(expectedValue));
 }
예제 #11
0
 public LWCInstruction(int copid,Register rs,int coprd,int imm)
 {
     this.copid = copid;
     this.rs = rs;
     this.coprd = coprd;
     this.imm = imm;
 }
예제 #12
0
파일: FrmMain.cs 프로젝트: hdxhan/IKendeLib
 private void cmdRegister_Click(object sender, EventArgs e)
 {
     Register reg = new Register();
     reg.UserName = txtName.Text;
     reg.EMail = txtEMail.Text;
     mChannel.Send(reg);
 }
예제 #13
0
파일: RegisterTest.cs 프로젝트: otf/VsVim
 public void ValueBackingTest2()
 {
     var backing = new MockRegisterValueBacking();
     var reg = new Register(RegisterName.Unnamed, backing);
     backing.Value = new RegisterValue(StringData.NewSimple("foo"), OperationKind.CharacterWise);
     Assert.AreEqual("foo", reg.StringValue);
 }
 public static void InverseAddModuloQFT(this QuantumComputer comp, ulong a, ulong N, RegisterRef ctrl, Register b, params RegisterRef[] controls)
 {
     Validate(a, b, N);
     comp.QFT(b);
     comp.InverseAddModuloQFTPhi(a, N, ctrl, b, controls);
     comp.InverseQFT(b);
 }
 /// <summary>
 /// Crates a new EEPROM Handler to enable EEPROM functionality.
 /// IMPORTANT: call dispose(); when it's no longer needed.
 /// </summary>
 /// <param name="_registerFileMap"></param>
 /// <param name="_eepromMemory"></param>
 public EEPROMHandler(Register.RegisterFileMap _registerFileMap, Data.EEPROMMemory _eepromMemory)
 {
     this.registerFileMap = _registerFileMap;
     this.eepromMemory = _eepromMemory;
     this.valueChangeListener = new Data.DataAdapter<byte>.OnDataChanged(onValueChange);
     registerSelfWithRegisterFileMap();
 }
 public void RegisterSelf(Register register)
 {
     contentTaskPane = register(() => new WpfPanelHost
     {
         Child = this
     }, "GitHub for Outlook", false);
 }
예제 #17
0
 public static void Reverse(this QuantumComputer comp, Register a)
 {
     for (int i = 0; i < a.Width / 2; i++)
     {
         comp.Swap(a[i], a[a.Width - 1 - i]);
     }
 }
예제 #18
0
 public static void AddQFT(this QuantumComputer comp, ulong a, Register b, params RegisterRef[] controls)
 {
     Validate(a, b);
     comp.QFT(b);
     comp.AddQFTPhi(a, b, controls);
     comp.InverseQFT(b);
 }
 public BitOperation(short _targetAddress, short _bitNumber, BitOperator _op, Register.RegisterFileMap _registerFileMap, short _address)
     : base(_registerFileMap, CYCLES, _address)
 {
     this.targetAddress = _targetAddress;
     this.bitNumber = _bitNumber;
     this.op = _op;
 }
 private static void Validate(Register target, ulong number)
 {
     if ((number >> target.Width) > 0)
     {
         throw new System.ArgumentException("Target register is too small. It must have enough space to store loaded number.");
     }
 }
예제 #21
0
 public void EmitMOV(Register regDst, Register regSrc)
 {
     AddrMode rexAddrMode = new AddrMode(regSrc, null, 0, 0, AddrModeSize.Int64);
     EmitRexPrefix(regDst, ref rexAddrMode);
     Builder.EmitByte(0x89);
     Builder.EmitByte((byte)(0xC0 | (((int)regSrc & 0x07) << 3) | (((int)regDst & 0x07))));
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public VariableStartEntry(int offset, Register register, IVariable variable, TypeReference type) : base(offset)
 {
     this.register = register;
     Variable = variable;
     name = variable.OriginalName;
     this.type = type;
 }
        // controlled loading a number into register
        // using Toffoli gates
        // if controlBits are empty, the number is loaded unconditionally
        public static void LoadNumber(this QuantumComputer comp, Register target, ulong number, params RegisterRef[] controlBits)
        {
            Validate(target, number);

            int controlLength = controlBits.Length;

            int i = 0;
            ulong tmpN = number;
            while (tmpN > 0)
            {
                int rest = (int)(tmpN % 2);
                tmpN = tmpN / 2;

                if (rest == 1)
                {
                    if (controlLength > 1)
                    {
                        comp.Toffoli(target[i], controlBits);
                    }
                    else if (controlLength > 0)
                    {
                        comp.CNot(target[i], controlBits[0]);
                    }
                    else
                    {
                        target.SigmaX(i);
                    }
                }
                i++;
            }
        }
        // register A - initially loaded with a
        // register B - initially loaded with b
        // register C - initially 0, exactly one bit wider than A, stores overflow bit
        // register N - initially loaded with N
        // after computation in register B: (a+b) mod N
        // other registers dont change their states
        // register B must be exactly one bit wider than A to store carry bit
        // register B must be exactly one bit wider than N to store carry bit
        // registers A, N must be the same length
        // Insecure version: registers widths etc. are not checked
        public static void AddModulo(
            this QuantumComputer comp,
            Register a,
            Register b,
            Register c,
            Register N,
            ulong valueN)
        {
            RegisterRef carry = b[b.Width - 1];
            RegisterRef overflow = c[c.Width - 1];

            comp.Add(a, b, c);
            comp.InverseAdd(N, b, c);
            comp.SigmaX(carry);
            comp.CNot(overflow, carry);
            comp.SigmaX(carry);

            //resetting N
            comp.LoadNumber(N, valueN, overflow);

            comp.Add(N, b, c);

            // now we have [(a+b) mod N] in B register
            // next steps lead to recover the initial state of registers N and overflow bit

            //setting N back
            comp.LoadNumber(N, valueN, overflow);

            comp.InverseAdd(a, b, c);
            comp.CNot(overflow, carry);
            comp.Add(a, b, c);
        }
예제 #25
0
        /// <summary>
        /// Replace all references to oldRegister with newRegister in the given instruction set.
        /// </summary>
        public void ReplaceRegisterWith(Register oldRegister, Register newRegister, MethodBody body)
        {
            var oldRegister2 = (oldRegister.Type == RType.Wide) ? body.GetNext(oldRegister) : null;
            var newRegister2 = (newRegister.Type == RType.Wide) ? body.GetNext(newRegister) : null;

            if (oldRegister.IsKeepWithNext != newRegister.IsKeepWithNext)
                throw new ArgumentException("New register has different keep-with-next value");

            HashSet<Instruction> list;
            if (map.TryGetValue(oldRegister, out list))
            {
                list.ForEach(x => x.ReplaceRegisterWith(oldRegister, newRegister));
                // Update newRegister
                AddRange(newRegister, list);
            }
            if (oldRegister2 != null)
            {
                if (map.TryGetValue(oldRegister2, out list))
                {
                    list.ForEach(x => x.ReplaceRegisterWith(oldRegister2, newRegister2));
                    // Update newRegister2
                    AddRange(newRegister2, list);
                }                
            }
        }
예제 #26
0
        // Add(a, b, 0) -> (a, a+b, 0)
        // Registers a, b and c must not overlap
        // Registers a and b have the same width
        // Register c is used for storing carries and must be minimum one bit wider than register a (or b)
        // Initial value of c must be 0
        public static void Add(this QuantumComputer comp,
            Register a, Register b, Register c)
        {
            if (comp.Group)
            {
                object[] parameters = new object[] { comp, a, b, c };
                comp.AddParametricGate("Add", parameters);
                return;
            }
            else
            {
                comp.Group = true;
            }

            int width = a.Width;
            int i = 0;
            for (; i < width - 1; i++)
            {
                comp.Carry(c[i], a[i], b[i], c[i + 1]);
            }
            comp.Carry(c[i], a[i], b[i], b[i + 1]);

            comp.CNot(b[i], a[i]);
            comp.Sum(c[i], a[i], b[i]);
            i--;
            for (; i >= 0; i--)
            {
                comp.InverseCarry(c[i], a[i], b[i], c[i + 1]);
                comp.Sum(c[i], a[i], b[i]);
            }
        }
예제 #27
0
        public static void AddQFTPhi(this QuantumComputer comp, Register a, Register b, params RegisterRef[] controls)
        {
            if (comp.Group)
            {
                object[] parameters = new object[] { comp, a, b, controls };
                comp.AddParametricGate("AddQFTPhi", parameters);
                return;
            }
            else
            {
                comp.Group = true;
            }

            Validate(a, b);

            for (int j = b.Width - 1; j >= 0; j--)
            {
                for (int i = j; i >= 0; i--)
                {
                    List<RegisterRef> list = controls.ToList<RegisterRef>();
                    list.Add(a[i]);
                    RegisterRef[] controls2 = list.ToArray();
                    comp.CPhaseShift(Math.Abs(j-i), b[j], controls2);
                }
            }
        }
 public RotateOperation(short _sourceAddress, short _targetAddress, RotationDirection _direction, Register.RegisterFileMap _registerFileMap, short _address)
     : base(_registerFileMap, CYCLES, _address)
 {
     this.data = _registerFileMap.Get(_sourceAddress);
     this.targetAddress = _targetAddress;
     this.direction = _direction;
 }
        // register x - initially loaded with x
        // register N - initially loaded with N
        // control - control bit
        // other registers - initially 0
        // after computation register B changes and contains: [(a*x) mod N]
        // Insecure version: registers widths etc. are not checked
        public static void CMultModulo(
            this QuantumComputer comp,
            Register a,
            Register b,
            Register c,
            Register N,
            Register x,
            RegisterRef control,
            ulong valueA,
            ulong valueN)
        {
            ulong power2 = 1;
            for (int i = 0; i < x.Width; i++, power2 *= 2)
            {
                // loading A register with (2^i * a) mod N
                ulong toLoad = (valueA * power2) % valueN;
                comp.LoadNumber(a, toLoad, control, x[i]);

                // adding [(2^i * a) + B] modulo N
                comp.AddModulo(a, b, c, N, valueN);

                // unloading [(2^i * a) mod N] from A register
                comp.LoadNumber(a, toLoad, control, x[i]);
            }

            // if control == 0
            // then B register contains still 0
            // so we copy X register into B register
            comp.SigmaX(control);
            for (int i = 0; i < x.Width; i++)
            {
                comp.Toffoli(b[i], control, x[i]);
            }
            comp.SigmaX(control);
        }
예제 #30
0
파일: Ram.cs 프로젝트: jw56578/WooComputer
 public RAM(int width, int registerWidth)
 {
     registers = new Register[width];
     for (int i = 0; i < registers.Length; i++) {
         registers[i] = new Register(registerWidth);
     }
 }
예제 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnboxAny"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="result">The result.</param>
 /// <param name="instance">The instance.</param>
 public UnboxAny(Class type, Register result, Register instance)
     : base("UnboxAny", result, new Operand [] { instance })
 {
     this.type = type;
 }
예제 #32
0
 /// <summary>
 /// Checks if it's <c>EIP</c>/<c>RIP</c>
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsIP(this Register register) => register == Register.EIP || register == Register.RIP;
예제 #33
0
 /// <summary>
 /// Checks if it's a 512-bit vector register (<c>ZMM0</c>-<c>ZMM31</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsZMM(this Register register) => Register.ZMM0 <= register && register <= IcedConstants.ZMM_last;
예제 #34
0
 /// <summary>
 /// Checks if it's a test register (<c>TR0</c>-<c>TR7</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsTR(this Register register) => Register.TR0 <= register && register <= Register.TR7;
예제 #35
0
 /// <summary>
 /// Checks if it's an 8-bit general purpose register (<c>AL</c>-<c>R15L</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsGPR8(this Register register) => Register.AL <= register && register <= Register.R15L;
예제 #36
0
 /// <summary>
 /// Checks if it's a segment register (<c>ES</c>, <c>CS</c>, <c>SS</c>, <c>DS</c>, <c>FS</c>, <c>GS</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsSegmentRegister(this Register register) => Register.ES <= register && register <= Register.GS;
예제 #37
0
 /// <summary>
 /// Checks if it's an <c>XMM</c>, <c>YMM</c> or <c>ZMM</c> register
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsVectorRegister(this Register register) => Register.XMM0 <= register && register <= IcedConstants.VMM_last;
예제 #38
0
 /// <summary>
 /// Checks if it's an MMX register (<c>MM0</c>-<c>MM7</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsMM(this Register register) => Register.MM0 <= register && register <= Register.MM7;
예제 #39
0
 /// <summary>
 /// Checks if it's a bound register (<c>BND0</c>-<c>BND3</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsBND(this Register register) => Register.BND0 <= register && register <= Register.BND3;
예제 #40
0
 /// <summary>
 /// Checks if it's an FPU stack register (<c>ST0</c>-<c>ST7</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsST(this Register register) => Register.ST0 <= register && register <= Register.ST7;
예제 #41
0
 /// <summary>
 /// Checks if it's a control register (<c>CR0</c>-<c>CR15</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsCR(this Register register) => Register.CR0 <= register && register <= Register.CR15;
예제 #42
0
 /// <summary>
 /// Checks if it's a debug register (<c>DR0</c>-<c>DR15</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsDR(this Register register) => Register.DR0 <= register && register <= Register.DR15;
		public static IEnumerable<Instruction> SpillRegister(Register reg, IEnumerable<Instruction> containedInstructions)
		{
			yield return Instruction.Create(Code.Push_r64, reg);
			foreach (var inst in containedInstructions) { yield return inst; }
			yield return Instruction.Create(Code.Pop_r64, reg);
		}
예제 #44
0
 /// <summary>
 /// Checks if it's an opmask register (<c>K0</c>-<c>K7</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsK(this Register register) => Register.K0 <= register && register <= Register.K7;
예제 #45
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Register.JavaScript(Page, @"
    $('.helpPanel').click(function () {
        var $hp = $(this);
        $hp.toggleClass('helpVisible');
    });

    // hide mce toolbar to prevent it getting skewed
    $('.tabs a').click(function () {
        $('.mceExternalToolbar').hide();
    });
    $('input').focus(function () {
        $('.mceExternalToolbar').hide();
    });

    $('.dimmable').n2dimmable();

    $('.uploader > label').n2revealer();

    $('.expandable').n2expandable({ visible: '.uncontractable' });

    $('form').n2expandableBox({ opener: '.rightOpener', opened: '#outside' });
    $('#outside .box').n2expandableBox({ opener: 'h4', opened: '.box-inner' });
", ScriptOptions.DocumentReady);

            Register.StyleSheet(Page, Url.ResolveTokens("{ManagementUrl}/Resources/Css/edit.css") + "?v=" + Register.CssVersion);

            Page.ClientScript.RegisterHiddenField(ClientID + "_autosaved_url", Page.Request[ClientID + "_autosaved_url"] ?? currentItem.ID.ToString());
            if (EnableAutoSave)
            {
                Register.JavaScript(Page, @"	window.n2autosave && n2autosave.init();", ScriptOptions.DocumentReady);

                TryAddItemReference(this);
                foreach (var placeholder in placeholders.Values)
                {
                    if (!TryAddItemReference(placeholder as WebControl))
                    {
                        if (placeholder.Controls.Count > 0)
                        {
                            TryAddItemReference(placeholder.Controls[0] as WebControl);
                        }
                    }
                }
            }
            else
            {
                TryAddDisabledAutosave(this);
                foreach (var placeholder in placeholders.Values)
                {
                    if (!TryAddDisabledAutosave(placeholder as WebControl))
                    {
                        if (placeholder.Controls.Count > 0)
                        {
                            TryAddDisabledAutosave(placeholder.Controls[0] as WebControl);
                        }
                    }
                }
            }
        }
예제 #46
0
 /// <summary>
 /// Gets the size of the register in bytes
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static int GetSize(this Register register) => register.GetInfo().Size;
예제 #47
0
 public void RegisterTaskPanes(Register register)
 {
     contentHost.RegisterSelf(register);
 }
예제 #48
0
 public override Result Execute()
 {
     register = new Register(receiver.RegisterUser);
     register.BeginInvoke(newUser, callbackMethod, this);
     return(new NullResult());
 }
예제 #49
0
 /// <summary>
 /// The register number (index) relative to <see cref="GetBaseRegister(Register)"/>, eg. 0-15, or 0-31, or if 8-bit GPR, 0-19
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static int GetNumber(this Register register) => register.GetInfo().Number;
예제 #50
0
 private void WriteRegister(Register register)
 {
     WakeUpDevice();
     _i2cDevice.WriteByte((byte)register);
     SleepDownDevice();
 }
예제 #51
0
 /// <summary>
 /// Gets the base register, eg. <c>AL</c>, <c>AX</c>, <c>EAX</c>, <c>RAX</c>, <c>MM0</c>, <c>XMM0</c>, <c>YMM0</c>, <c>ZMM0</c>, <c>ES</c>
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static Register GetBaseRegister(this Register register) => register.GetInfo().Base;
예제 #52
0
 /// <summary>
 /// Gets the full register that this one is a part of, except if it's a GPR in which case the 32-bit register is returned,
 /// eg. CL/CH/CX/ECX/RCX -> ECX, XMM11/YMM11/ZMM11 -> ZMM11
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static Register GetFullRegister32(this Register register) => register.GetInfo().FullRegister32;
예제 #53
0
        public static void InverseControlledUaGate(this QuantumComputer comp, ulong a, ulong N, RegisterRef ctrl, Register x, Register reg0, RegisterRef control)
        {
            if (comp.Group)
            {
                object[] parameters = new object[] { comp, a, N, ctrl, x, reg0, control };
                comp.AddParametricGate("InverseControlledUaGate", parameters);
                return;
            }
            else
            {
                comp.Group = true;
            }

            Validate(x, N);

            int?invA = Quantum.Utils.InversionModulo((int)a, (int)N);

            if (invA == null)
            {
                throw new ArgumentException("No inversion for specified a");
            }

            comp.MultModuloQFT((ulong)invA, N, ctrl, x, reg0, control);
            comp.Swap(reg0, x, control);
            comp.InverseMultModuloQFT(a, N, ctrl, x, reg0, control);
        }
예제 #54
0
        protected override void RegisterToolbarSelection()
        {
            string script = GetToolbarSelectScript("preview");

            Register.JavaScript(this, script, ScriptPosition.Bottom, ScriptOptions.ScriptTags);
        }
예제 #55
0
        public static void InverseControlledUaGate(this QuantumComputer comp, ulong a, ulong N, Register x, RegisterRef control)
        {
            if (comp.Group)
            {
                object[] parameters = new object[] { comp, a, N, x, control };
                comp.AddParametricGate("InverseControlledUaGate", parameters);
                return;
            }
            else
            {
                comp.Group = true;
            }

            Register ctrl = comp.NewRegister(0, 1);
            Register reg0 = comp.NewRegister(0, x.Width);

            comp.InverseControlledUaGate(a, N, ctrl, x, reg0, control);
        }
예제 #56
0
 private short ReadRegisterInt16(Register register)
 {
     return(ReadRegisterInt16((byte)register));
 }
예제 #57
0
 /// <summary>
 /// Checks if it's a 32-bit general purpose register (<c>EAX</c>-<c>R15D</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsGPR32(this Register register) => Register.EAX <= register && register <= Register.R15D;
예제 #58
0
 /// <summary>
 /// Checks if it's a 64-bit general purpose register (<c>RAX</c>-<c>R15</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsGPR64(this Register register) => Register.RAX <= register && register <= Register.R15;
예제 #59
0
 /// <summary>
 /// Checks if it's a 16-bit general purpose register (<c>AX</c>-<c>R15W</c>)
 /// </summary>
 /// <param name="register">Register</param>
 /// <returns></returns>
 public static bool IsGPR16(this Register register) => Register.AX <= register && register <= Register.R15W;
예제 #60
0
 /// <summary>
 /// Adds an instruction to the end of the code
 /// </summary>
 /// <param name="command">The instruction's command</param>
 /// <param name="register">The instruction's register argument</param>
 /// <param name="length">The instruction's length argument</param>
 /// <param name="offsetOrValue">The instruction's offset or value argument</param>
 public void AddInstruction(OpCode command, Register register, byte length, short offsetOrValue)
 {
     AddInstruction(new Instruction(command, register, length, offsetOrValue));
 }