Beispiel #1
0
        private static void Set(string encoding, InstEmitter emitter, MakeOp makeOp)
        {
            if (encoding.Length != EncodingBits)
            {
                throw new ArgumentException(nameof(encoding));
            }

            int bit   = encoding.Length - 1;
            int value = 0;
            int xMask = 0;
            int xBits = 0;

            int[] xPos = new int[encoding.Length];

            for (int index = 0; index < encoding.Length; index++, bit--)
            {
                char chr = encoding[index];

                if (chr == '1')
                {
                    value |= 1 << bit;
                }
                else if (chr == 'x')
                {
                    xMask |= 1 << bit;

                    xPos[xBits++] = bit;
                }
            }

            xMask = ~xMask;

            TableEntry entry = new TableEntry(emitter, makeOp, xBits);

            for (int index = 0; index < (1 << xBits); index++)
            {
                value &= xMask;

                for (int x = 0; x < xBits; x++)
                {
                    value |= ((index >> x) & 1) << xPos[x];
                }

                if (_opCodes[value] == null || _opCodes[value].XBits > xBits)
                {
                    _opCodes[value] = entry;
                }
            }
        }
Beispiel #2
0
        private static OpCode MakeOpCode(InstDescriptor inst, Type type, ulong address, int opCode)
        {
            MakeOp createInstance = _opActivators.GetOrAdd(type, CacheOpActivator);

            return((OpCode)createInstance(inst, address, opCode));
        }
Beispiel #3
0
 public TableEntry(InstEmitter emitter, MakeOp makeOp, int xBits)
 {
     Emitter = emitter;
     MakeOp  = makeOp;
     XBits   = xBits;
 }