Esempio n. 1
0
        private int getValue(uint target)
        {
            bool isMemLocation = (CPUBasic.FLAG_MEM_OR_NUM & target) > 0;
            bool isJump        = (CPUBasic.FLAG_JUMP_ADDRESS & target) > 0;
            bool isBitAccess   = (CPUBasic.FLAG_BIT_ACCESS & target) > 0;
            uint len           = (CPUBasic.FLAG_BITFIELD_VAL & target) >> 20;

            CPUBasic.eMemRange witchMem = (CPUBasic.FLAG_MEM_MARKER & target) > 0 ? CPUBasic.eMemRange.MARKER : CPUBasic.eMemRange.NONE;
            witchMem = (CPUBasic.FLAG_MEM_OUTPUT & target) > 0 ? CPUBasic.eMemRange.OUTPUT : witchMem;
            witchMem = (CPUBasic.FLAG_MEM_INPUT & target) > 0 ? CPUBasic.eMemRange.INPUT : witchMem;

            int value = 0;

            if (isMemLocation)
            {
                value = (int)(CPUBasic.FLAG_MEMADR & target);
            }
            else
            {
                value = (int)target;
            }

            int memValue = getValueMem(isBitAccess, witchMem, value, (int)len);

            return(memValue);
        }
Esempio n. 2
0
        private int getValueMem(bool isBit, CPUBasic.eMemRange range, int targetVal, int bitfield)
        {
            int akkuVal = 0;

            switch (range)
            {
            case CPUBasic.eMemRange.MARKER:
                if (isBit)
                {
                    akkuVal = m_byaMarkerMemory[targetVal] & CPUBasic.BITVALUES[bitfield];
                }
                else
                {
                    for (int i = 0; i < bitfield; i++)
                    {
                        akkuVal |= m_byaMarkerMemory[targetVal + i] << (i * 8);
                    }
                }
                break;

            case CPUBasic.eMemRange.OUTPUT:
                if (isBit)
                {
                    akkuVal = m_byaOutputMemory[targetVal] & CPUBasic.BITVALUES[bitfield];
                }
                else
                {
                    for (int i = 0; i < bitfield; i++)
                    {
                        akkuVal |= m_byaOutputMemory[targetVal + i] << (i * 8);
                    }
                }
                break;

            case CPUBasic.eMemRange.INPUT:
                if (isBit)
                {
                    akkuVal = m_byaInputMemory[targetVal] & CPUBasic.BITVALUES[bitfield];
                }
                else
                {
                    for (int i = 0; i < bitfield; i++)
                    {
                        akkuVal |= m_byaInputMemory[targetVal + i] << (i * 8);
                    }
                }
                break;
            }

            return(akkuVal);
        }