Exemplo n.º 1
0
        //stores generic information about all decoded arm instructions

        //decodes bits 27-26 and returns specified instruction type
        public static Instructions decode(uint instruction, Registers myRegisters, Memory myMemory, bool disassembling)
        {

            // check opcodes here
            dontDoItBro = false;
            firstOpcode = passOpcode(getSectionValue(31, 28, instruction), myMemory);
            if (firstOpcode == null)
            {
                dontDoItBro = true;
                return null;
                //get outta here. this instructions a bad one
            }

            //handle specials here
            In_Special sInstruction = new In_Special(myRegisters, myMemory, instruction, disassembling);

            if (sInstruction.isSpecial())
            {
                return sInstruction;
            }

            if (getSectionValue(27, 20, instruction) == 18 && getSectionValue(7, 4, instruction) == 1)
            {
                return new In_Branch(myRegisters, myMemory, instruction, disassembling);
            }

            else
            {
                //previously checked only bits 27, - 26
                uint type = getSectionValue(27, 25, instruction);
                if (type == 0 || type == 1)
                {
                    return new In_DataProcessing(myRegisters, myMemory, instruction, disassembling);
                }
                if (type == 2 || type == 3 || type == 4)
                {
                    return new In_LoadStore(myRegisters, myMemory, instruction, disassembling);
                }
                else
                {
                    return new In_Branch(myRegisters, myMemory, instruction, disassembling);
                }
            }
        }
Exemplo n.º 2
0
        //stores generic information about all decoded arm instructions

        //decodes bits 27-26 and returns specified instruction type
        public static Instructions decode(uint instruction, Registers myRegisters, Memory myMemory, bool disassembling)
        {
            // check opcodes here
            dontDoItBro = false;
            firstOpcode = passOpcode(getSectionValue(31, 28, instruction), myMemory);
            if (firstOpcode == null)
            {
                dontDoItBro = true;
                return(null);
                //get outta here. this instructions a bad one
            }

            //handle specials here
            In_Special sInstruction = new In_Special(myRegisters, myMemory, instruction, disassembling);

            if (sInstruction.isSpecial())
            {
                return(sInstruction);
            }

            if (getSectionValue(27, 20, instruction) == 18 && getSectionValue(7, 4, instruction) == 1)
            {
                return(new In_Branch(myRegisters, myMemory, instruction, disassembling));
            }

            else
            {
                //previously checked only bits 27, - 26
                uint type = getSectionValue(27, 25, instruction);
                if (type == 0 || type == 1)
                {
                    return(new In_DataProcessing(myRegisters, myMemory, instruction, disassembling));
                }
                if (type == 2 || type == 3 || type == 4)
                {
                    return(new In_LoadStore(myRegisters, myMemory, instruction, disassembling));
                }
                else
                {
                    return(new In_Branch(myRegisters, myMemory, instruction, disassembling));
                }
            }
        }