예제 #1
0
        private void GetRegistersFromNative()
        {
            int    cRegs;
            IntPtr aRegs;

            native.GetAllRegisters(0, out cRegs, out aRegs);
            if (aRegs == null)
            {
                throw new OutOfMemoryException();
            }
            this.regsByName   = new Dictionary <string, RegisterStorage>();
            this.regsByNumber = new Dictionary <int, RegisterStorage>();
            NativeRegister nReg = new NativeRegister();
            int            cb   = Marshal.SizeOf(nReg);

            while (cRegs > 0)
            {
                nReg = (NativeRegister)Marshal.PtrToStructure(aRegs, typeof(NativeRegister));
                if (nReg.Name != null)
                {
                    var n   = nReg.Name;
                    var i   = nReg.Number;
                    var b   = nReg.BitSize;
                    var reg = new RegisterStorage(n, i, 0, PrimitiveType.CreateWord(b));
                    regsByName.Add(reg.Name, reg);
                    regsByNumber.Add(reg.Number, reg);
                }
                aRegs += cb;
                --cRegs;
            }
        }
예제 #2
0
        private void GetRegisterOfType(int registerKind)
        {
            native.GetAllRegisters(registerKind, out int cRegs, out IntPtr aRegs);
            if (aRegs == null)
            {
                throw new OutOfMemoryException();
            }
            NativeRegister nReg = new NativeRegister();
            int            cb   = Marshal.SizeOf(nReg);

            while (cRegs > 0)
            {
                nReg = (NativeRegister)Marshal.PtrToStructure(aRegs, typeof(NativeRegister));
                if (nReg.Name != null)
                {
                    var n   = nReg.Name;
                    var i   = nReg.Number;
                    var b   = nReg.BitSize;
                    var a   = (uint)nReg.BitOffset;
                    var reg = new RegisterStorage(n, i, a, PrimitiveType.CreateWord(b));
                    regsByName.Add(reg.Name, reg);
                    regsByNumber.Add(reg.Number, reg);
                }
                aRegs += cb;
                --cRegs;
            }
        }