Пример #1
0
        /// <summary>
        /// Formats an instruction argument based on the argument type.
        /// </summary>
        internal static string GetArg(InstructionArgumentType arg, Instruction ins)
        {
            switch (arg)
            {
            case InstructionArgumentType.Rs:
                return("$" + InstructionSet.RegisterNames[ins.Rs]);

            case InstructionArgumentType.Rt:
                return("$" + InstructionSet.RegisterNames[ins.Rt]);

            case InstructionArgumentType.Rd:
                return("$" + InstructionSet.RegisterNames[ins.Rd]);

            case InstructionArgumentType.Immediate:
            case InstructionArgumentType.Label:
                if (ins.OpCode == OpCode.j || ins.OpCode == OpCode.jal)
                {
                    return("0x" + (ins.Target << 2).ToString("X"));
                }
                else
                {
                    return("0x" + ins.Immediate.ToString("X"));
                }

            case InstructionArgumentType.ImmediateRs:
                return(string.Format("{1}(${0})", InstructionSet.RegisterNames[ins.Rs], ins.Immediate));

            case InstructionArgumentType.Sa:
                return(ins.sa.ToString());

            default:
                return(string.Empty);
            }
        }
Пример #2
0
 public InstructionDescription(string mnemonic, InstructionArgumentType[] args, string description)
 {
     this.mnemonic = mnemonic;
     this.args = args;
     this.description = description;
 }