예제 #1
0
파일: CmdLW.cs 프로젝트: GoneUp/MipsCycler
        public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
        {
            if (info.name == "la")
            {
                if (!dataTable.ContainsKey(pseudoLabel))
                {
                    throw new ArgumentException("label not found! " + ToString());
                }

                regs.Registers[rt] = dataTable[pseudoLabel];
            }
            else if (info.name == "lw")
            {
                if (pseudoLabel != "")
                {
                    if (!dataTable.ContainsKey(pseudoLabel))
                    {
                        throw new ArgumentException("label not found! " + ToString());
                    }

                    regs.Registers[rt] = memory.CmdLoadWord(dataTable[pseudoLabel]);
                }
                else
                {
                    regs.Registers[rt] = memory.CmdLoadWord(regs.Registers[rs] + immediate);
                }
            }
            else if (info.name == "sw")
            {
                memory.CmdSaveWord(regs.Registers[rs] + immediate, regs.Registers[rt]);
            }
        }
예제 #2
0
파일: CmdSlt.cs 프로젝트: GoneUp/MipsCycler
 public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
 {
     switch (info.name)
     {
     case "slt":
         regs.Registers[rd] = regs.Registers[rs] < regs.Registers[rt] ? 1 : 0;
         break;
     }
 }
예제 #3
0
 public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
 {
     switch (info.name)
     {
     case "addi":
         regs.Registers[rt] = regs.Registers[rs] + immediate;
         break;
     }
 }
예제 #4
0
        public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
        {
            if (!linkerTable.ContainsKey(jumpLabel))
            {
                throw new ArgumentException("jump label not found! " + ToString());
            }

            regs.PC = linkerTable[jumpLabel];
        }
예제 #5
0
        public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
        {
            if (!linkerTable.ContainsKey(bLabel))
            {
                throw new ArgumentException("branch label not found! " + ToString());
            }

            if (info.name == "beq" && regs.Registers[rs] == regs.Registers[rt])
            {
                regs.PC = linkerTable[bLabel];
            }

            if (info.name == "bne" && regs.Registers[rs] != regs.Registers[rt])
            {
                regs.PC = linkerTable[bLabel];
            }
        }
예제 #6
0
        public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
        {
            switch (info.name)
            {
            case "sll":
                regs.Registers[rd] = (int)(((uint)regs.Registers[rt]) << shift);
                break;

            case "srl":
                regs.Registers[rd] = (int)(((uint)regs.Registers[rt]) >> shift);
                break;

            case "sra":
                regs.Registers[rd] = regs.Registers[rt] >> shift;
                break;
            }
        }
예제 #7
0
        public void execute(MipsMemory memory, Dictionary <string, int> dataTable)
        {
            string[] split   = args.Split(' ');
            int      pointer = 0;

            switch (instruction)
            {
            case ".word":
                int[] intArray = new int[split.Length];
                for (int i = 0; i < split.Length; i++)
                {
                    intArray[i] = Convert.ToInt32(split[i]);
                }
                pointer = memory.SaveWords(intArray);
                break;

            case ".half":
                short[] halfArray = new short[split.Length];
                for (int i = 0; i < split.Length; i++)
                {
                    halfArray[i] = Convert.ToInt16(split[i]);
                }
                pointer = memory.SaveHalfs(halfArray);
                break;

            case ".byte":
                byte[] byteArray = new byte[split.Length];
                for (int i = 0; i < split.Length; i++)
                {
                    byteArray[i] = Convert.ToByte(split[i]);
                }
                pointer = memory.SaveBytes(byteArray);
                break;

            case ".space":
                int count = Convert.ToInt32(split[0]);
                pointer = memory.ReserveBytes(count);
                break;
            }


            if (label != "")
            {
                dataTable.Add(label, pointer);
            }
        }
예제 #8
0
 public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable)
 {
     throw new NotImplementedException();
 }
예제 #9
0
 public abstract void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable);