Пример #1
0
        private int ParseCommandWithNoImm(string[][] programTextArray, ref int i, ref int j,
                                          Dictionary <uint, ExeCommand> commandsToExe)
        {
            int result;

            switch (programTextArray[i][j])
            {
            case "add":
            case "sub":
            case "sll":
            case "slt":
            case "sltu":
            case "xor":
            case "srl":
            case "sra":
            case "or":
            case "and":
                result = Instructions.RInstruction(programTextArray, ref i, ref j, commandsToExe);
                break;

            case "lb":
            case "lh":
            case "lw":
            case "lbu":
            case "lhu":
                result = Instructions.LoadIInstruction(programTextArray, ref i, ref j, commandsToExe);
                break;

            case "sb":
            case "sh":
            case "sw":
                result = Instructions.StoreInstruction(programTextArray, ref i, ref j, commandsToExe);
                break;

            case "beq":
            case "bne":
            case "blt":
            case "bge":
            case "bltu":
            case "bgeu":
                result = Instructions.BInstruction(programTextArray, ref i, ref j, commandsToExe);
                break;

            case "jal":
            case "j":
                result = Instructions.JInstruction(programTextArray, ref i, ref j, commandsToExe);
                break;

            case "ecall":
            case "ebreak":
                result = Instructions.EInstruction(programTextArray, ref i, ref j, commandsToExe);
                break;

            default:
                return(0);
            }

            return(result);
        }