private void DoInspectTypePopup() { EditorGUI.BeginChangeCheck(); InstructionType type = (InstructionType) EditorGUILayout.EnumPopup(this.m_InstructionType, EditorStyles.toolbarDropDown, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_InstructionType = type; switch (this.m_InstructionType) { case InstructionType.Draw: this.m_InstructionModeView = new StyleDrawInspectView(this); break; case InstructionType.Clip: this.m_InstructionModeView = new GUIClipInspectView(this); break; case InstructionType.Layout: this.m_InstructionModeView = new GUILayoutInspectView(this); break; case InstructionType.Unified: this.m_InstructionModeView = new UnifiedInspectView(this); break; } this.m_InstructionModeView.UpdateInstructions(); } }
public GameInstruction(InstructionType type, GameObject go, GameDirection direction, float value) { this.type = type; this.go = go; this.direction = direction; this.value = value; }
public void Decode_CorrectlyDecodesInstructions(UInt64 raw, InstructionType expectedOp, Int32 expecteOperand) { // Arrange var decoder = new Decoder(); // Act var instruction = decoder.Decode(raw); // Assert instruction.Type.Should().Be(expectedOp); instruction.Operand.Should().Be(expecteOperand); }
public void Encode_EncodesInstructionsCorrectly(InstructionType op, Int32? operand, UInt64 expected) { // Arrange var encoder = new Encoder(); var instruction = new Instruction { Type = op, Operand = operand.HasValue ? operand.Value : 0 }; // Act var encodedInstruction = encoder.Encode(instruction); // Assert encodedInstruction.Should().Be(expected); }
public void Encode_DoesIgnoresOperandForNonOperandInstructions(InstructionType op, Int32 operand, UInt64 expected) { // Arrange var encoder = new Encoder(); var instruction = new Instruction { Type = op, Operand = operand }; // Act var encodedInstruction = encoder.Encode(instruction); // Assert encodedInstruction.Should().Be(expected); }
protected BaseInspectView GetInspectViewForType(InstructionType type) { switch (type) { case InstructionType.kStyleDraw: return this.m_InstructionStyleView; case InstructionType.kClipPush: case InstructionType.kClipPop: return this.m_InstructionClipView; case InstructionType.kLayoutBeginGroup: case InstructionType.kLayoutEndGroup: case InstructionType.kLayoutEntry: return this.m_InstructionLayoutView; } throw new NotImplementedException("Unhandled InstructionType"); }
private static string GenerateInstructionLineText(InstructionCode instructionCode, byte operandByte1, byte operandByte2) { InstructionType instructionType = instructionCode.InstructionType; string instructionText = "\t" + instructionType.OpCodeName; if (instructionCode.IsDuplicate) { string instrCodeBytes = ""; if (instructionCode.Prefix != null) { foreach (byte b in instructionCode.Prefix) { instrCodeBytes += b.ToString("X2") + "H "; } } instrCodeBytes += instructionCode.OpCode.ToString("X2"); instructionText += "[" + instrCodeBytes + "H]"; } if (instructionType.Param1Type.HasValue) { AddressingMode paramType = instructionType.Param1Type.Value; string enumString = instructionCode.Param1.ToString(); instructionText += " " + GetParamTextFromEnumStringAndOperand(instructionType, paramType, enumString, false, operandByte1, operandByte2); } if (instructionType.Param2Type.HasValue) { AddressingMode paramType = instructionType.Param2Type.Value; string enumString = instructionCode.Param2.ToString(); instructionText += "," + GetParamTextFromEnumStringAndOperand(instructionType, paramType, enumString, false, operandByte1, operandByte2); } if (instructionType.Param3Type.HasValue) { AddressingMode paramType = instructionType.Param3Type.Value; string enumString = instructionCode.Param3.ToString(); instructionText += "," + GetParamTextFromEnumStringAndOperand(instructionType, paramType, enumString, false, operandByte1, operandByte2); } return(instructionText); }
public IInstruction GetInstructionForLine(Line line) { var filtered = _instructions.Where(i => i.Mnemonic.ToUpper() == line.Instruction.Source.ToUpper()); if (!filtered.Any()) { throw new Exception($"The instruction {line.Instruction.Source} on line {line.LineNumber} is not a valid instruction ({line.Source})"); } InstructionType type = InstructionType.None; if (line.Arguments.Length > 0) { type = line.Arguments[0].GetArgType(); } var selected = filtered.FirstOrDefault(i => i.ArgType == type); if (selected == null) { throw new Exception($"The instruction {line.Instruction.Source} on line {line.LineNumber} has invalid arguments ({line.Source})"); } return(selected); }
private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= dataGridView1.Rows.Count) { return; } switch (e.ColumnIndex) { case 0: break; case 1: break; case 2: if (e.RowIndex < 0 || e.RowIndex >= dataGridView1.Rows.Count) { return; } if (e.ColumnIndex != 2) { return; } if (dataGridView1[e.ColumnIndex, e.RowIndex].Value == null) { return; } var nameOfInstruction = dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString().Substring(0, 3); InstructionType type = (InstructionType)Enum.Parse(typeof(InstructionType), nameOfInstruction); dataGridView1[e.ColumnIndex, e.RowIndex].ToolTipText = Helper.InstructionDescriptions[type]; break; } }
public static string AsPrefixString(this InstructionType type) { switch (type) { case InstructionType.Set: return(PrefixForSetInstruction); case InstructionType.Add: return(PrefixForAddInstruction); case InstructionType.AddForce: return(PrefixForAddForceInstruction); case InstructionType.Remove: return(PrefixForRemoveInstruction); case InstructionType.RemoveAll: return(PrefixForRemoveAllInstruction); default: throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(InstructionType)); } }
public Instruction(string instructionType, int?argument) { switch (instructionType) { case "nop": InstructionType = InstructionType.NoOperation; break; case "acc": InstructionType = InstructionType.Accumulator; break; case "jmp": InstructionType = InstructionType.Jump; break; default: throw new InvalidOperationException($"InstructionType {instructionType} is not supported"); } Argument = argument; Id = Guid.NewGuid(); }
static public Instruction Toggle(Instruction source) { InstructionType type = InstructionType.Invalid; switch (source.Type) { case InstructionType.Increment: type = InstructionType.Decrement; break; case InstructionType.Decrement: type = InstructionType.Increment; break; case InstructionType.CopyValue: type = InstructionType.JumpValue; break; case InstructionType.CopyRegister: type = InstructionType.JumpRegister; break; case InstructionType.JumpValue: type = InstructionType.CopyValue; break; case InstructionType.JumpRegister: type = InstructionType.CopyRegister; break; case InstructionType.Toggle: type = InstructionType.Increment; break; } return(new Instruction(type, source.Register, source.SourceRegister, source.Value, source.SourceValue)); }
public Instruction(Opcodes opCode, string operand1, string operand2, string operand3) { opcode = opCode; dest = operand1; j = operand2; k = operand3; issued = executed = completed = false; switch (opCode) { case Opcodes.ADDD: case Opcodes.SUBD: instType = InstructionType.Add; break; case Opcodes.MULD: case Opcodes.DIVD: instType = InstructionType.Multiply; break; case Opcodes.LD: instType = InstructionType.Load; break; case Opcodes.SD: instType = InstructionType.Store; break; case Opcodes.BEQ: case Opcodes.BGEZ: case Opcodes.BLEZ: case Opcodes.BNE: instType = InstructionType.Branch; break; } }
public static Instruction Parse(string input) { string[] split = input.Split(" ,g".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries).ToArray(); InstructionType type = InstructionType.Invalid; switch (split[1][1]) { case 'n': type = InstructionType.On; break; case 'f': type = InstructionType.Off; break; case 'e': type = InstructionType.Toggle; break; } int[] intVals = split.Where(s => { int i; return(int.TryParse(s, out i)); }).Select(int.Parse).ToArray(); return(new Instruction(type, intVals[0], intVals[2], intVals[1], intVals[3])); }
public override string ToString() { string retValue = "Instruction"; switch (InstructionType) { case InstructionType.INC: retValue = String.Format("{0} ({1:0.000}kPa/s, {2:0.00}s)", InstructionType.ToString(), MAX_PRESSURE * Argument / 255, ((double)Steps) / UPDATE_RATE); break; case InstructionType.DEC: retValue = String.Format("{0} (-{1:0.000}kPa/s, {2:0.00}s)", InstructionType.ToString(), MAX_PRESSURE * Argument / 255, ((double)Steps) / UPDATE_RATE); break; case InstructionType.STEP: retValue = String.Format("{0} ({1:0.000}kPa, {2:0.00}s)", InstructionType.ToString(), MAX_PRESSURE * Argument / 255, ((double)Steps) / UPDATE_RATE); break; case InstructionType.NOP: retValue = String.Format("{0} ({1:0.00}s)", InstructionType.ToString(), ((double)Steps) / UPDATE_RATE);; break; } return(retValue); }
internal bool ContainsInstruction(InstructionType switchType) { return ByType(switchType) != null; }
public override void clockRise() { switch (state) { case Cycle.Off: break; case Cycle.Init: break; case Cycle.Fetch: bus.op = MainBus.OP.ld_4b; currentPC = registers.getR(Register.PC); bus.address = currentPC; bus.data = 0; break; case Cycle.Decode: currenOPCODE = (byte)(0b0111_1111 & (byte)currentInstruction); InstructionType op = (InstructionType)(0b0111_1100 & currenOPCODE); switch (op) { case InstructionType.LOAD: currentInstructionType = INST_TYPE.IType; break; case InstructionType.OP: currentInstructionType = INST_TYPE.RType; break; case InstructionType.OP_IMM: currentInstructionType = INST_TYPE.IType; break; case InstructionType.LOAD_FP: case InstructionType.CUSTOM_0: case InstructionType.MISC_MEM: case InstructionType.AUIPC: break; case InstructionType.OP_IMM_32: currentInstructionType = INST_TYPE.IType; break; case InstructionType.STORE: currentInstructionType = INST_TYPE.SType; break; case InstructionType.STORE_FP: case InstructionType.CUSTOM_1: case InstructionType.AMO: case InstructionType.LUI: case InstructionType.OP_32: case InstructionType.MADD: case InstructionType.MSUB: case InstructionType.NMSUB: case InstructionType.NMADD: case InstructionType.OP_FP: case InstructionType.RESERVED_0: case InstructionType.CUSTOM_2: break; case InstructionType.BRANCH: currentInstructionType = INST_TYPE.BType; break; case InstructionType.JALR: case InstructionType.RESERVED_1: case InstructionType.JAL: case InstructionType.SYSTEM: case InstructionType.RESERVED_2: case InstructionType.CUSTOM_3: default: break; } switch (currentInstructionType) { case INST_TYPE.RType: currentRType.Decode(currentInstruction); break; case INST_TYPE.IType: currentIType.Decode(currentInstruction); break; case INST_TYPE.SType: currentSType.Decode(currentInstruction); break; case INST_TYPE.BType: currentBType.Decode(currentInstruction); break; case INST_TYPE.UType: currentUType.Decode(currentInstruction); break; case INST_TYPE.JType: currentJType.Decode(currentInstruction); break; case INST_TYPE.Unkwn: default: throw new NotImplementedException("Instruction Type Not Set Correctly"); } break; case Cycle.Read: switch (currentInstructionType) { case INST_TYPE.RType: currentReadRS1 = registers.getR(currentRType.rs1); currentReadRS2 = registers.getR(currentRType.rs2); break; case INST_TYPE.IType: currentReadRS1 = registers.getR(currentIType.rs1); break; case INST_TYPE.SType: currentReadRS1 = registers.getR(currentSType.rs1); currentReadRS2 = registers.getR(currentSType.rs2); break; case INST_TYPE.BType: currentReadRS1 = registers.getR(currentBType.rs1); currentReadRS2 = registers.getR(currentBType.rs2); break; case INST_TYPE.UType: break; case INST_TYPE.JType: break; case INST_TYPE.Unkwn: default: throw new NotImplementedException("Instruction Type Not Set Correctly"); } break; case Cycle.Exec: switch ((OPCODE)currenOPCODE) { case OPCODE.B32_LOAD_IMM: bus.address = (ulong)((long)currentReadRS1 + currentIType.imm); //Set target Address bus.data = 0; //Clear the bus pipeWriteMode = PIPELINE_WRITE_MODE.LOAD_TO_REGISTER; // Tell write cycle what we want to do. pipeWriteAddress = (byte)currentIType.rd; // Tell write cycle where we want to do it. switch ((FUNC3_MEMORY)currentIType.func3) { case FUNC3_MEMORY.UNSIGNED_BYTE: case FUNC3_MEMORY.BYTE: pipeWriteByteCount = 1; bus.op = MainBus.OP.ld_1b; break; case FUNC3_MEMORY.UNSIGNED_HALFWORD: case FUNC3_MEMORY.HALFWORD: pipeWriteByteCount = 2; bus.op = MainBus.OP.ld_2b; break; case FUNC3_MEMORY.UNSIGNED_WORD: case FUNC3_MEMORY.WORD: pipeWriteByteCount = 4; bus.op = MainBus.OP.ld_4b; break; case FUNC3_MEMORY.UNSIGNED_DOUBLEWORD: case FUNC3_MEMORY.DOUBLEWORD: pipeWriteByteCount = 8; bus.op = MainBus.OP.ld_8b; break; default: throw new Exception("KORE HARDWARE PANIC", new Exception("Unsigned FUNC3 Store OPs are not supported.")); } if (currentIType.func3 == (byte)FUNC3_MEMORY.UNSIGNED_BYTE || currentIType.func3 == (byte)FUNC3_MEMORY.UNSIGNED_HALFWORD || currentIType.func3 == (byte)FUNC3_MEMORY.UNSIGNED_WORD || currentIType.func3 == (byte)FUNC3_MEMORY.UNSIGNED_DOUBLEWORD) { pipeWriteData = 0; // Tell Pipe to NOT sign extend } else { pipeWriteData = 1; // Tell Pipe to sign extend } break; case OPCODE.B32_ADDI: //ADDI is not the correct term for this but I have not gotten to the correct one yet switch (currentIType.func3) { case 0b000: //ADDI pipeWriteMode = PIPELINE_WRITE_MODE.WRITE_REGISTER; pipeWriteAddress = (ulong)currentIType.rd; pipeWriteData = (ulong)((long)currentReadRS1 + currentIType.imm); pipeWriteByteCount = 8; break; default: break; } break; case OPCODE.B32_OP: //ADD is not the correct term for this but I have not gotten to the correct one yet switch ((FUNC3_ALU)currentIType.func3) { case FUNC3_ALU.ADD: //ADD pipeWriteMode = PIPELINE_WRITE_MODE.WRITE_REGISTER; pipeWriteAddress = (ulong)currentRType.rd; if (currentRType.func7 == 0b0100000) { pipeWriteData = currentReadRS1 - currentReadRS2; } else { pipeWriteData = currentReadRS1 + currentReadRS2; } pipeWriteByteCount = 8; break; case FUNC3_ALU.SLL: case FUNC3_ALU.SLT: case FUNC3_ALU.SLTU: case FUNC3_ALU.XOR: case FUNC3_ALU.SR: case FUNC3_ALU.OR: case FUNC3_ALU.AND: default: break; } break; case OPCODE.B32_BRANCH: currentBranch = (ulong)((long)currentPC + (long)currentBType.imm); switch (currentBType.func3) { case 0b000: //BEQ currentBranchPending = currentReadRS1 == currentReadRS2; break; case 0b001: //BNE currentBranchPending = currentReadRS1 != currentReadRS2; break; case 0b010: //? case 0b011: //? break; case 0b100: //BLT (signed) currentBranchPending = (long)currentReadRS1 < (long)currentReadRS2; break; case 0b101: //BGE (signed) currentBranchPending = (long)currentReadRS1 >= (long)currentReadRS2; break; case 0b110: //BLTU (unsigned) currentBranchPending = currentReadRS1 < currentReadRS2; break; case 0b111: //BGEU (unsigned) currentBranchPending = currentReadRS1 >= currentReadRS2; break; default: break; } break; case OPCODE.B32_STORE_S: pipeWriteMode = PIPELINE_WRITE_MODE.WRITE_MEMORY; pipeWriteAddress = (ulong)((long)currentReadRS1 + currentSType.imm); pipeWriteData = currentReadRS2; switch ((FUNC3_MEMORY)currentSType.func3) { case FUNC3_MEMORY.BYTE: pipeWriteByteCount = 1; break; case FUNC3_MEMORY.HALFWORD: pipeWriteByteCount = 2; break; case FUNC3_MEMORY.WORD: pipeWriteByteCount = 4; break; case FUNC3_MEMORY.DOUBLEWORD: pipeWriteByteCount = 8; break; default: throw new Exception("KORE HARDWARE PANIC", new Exception("Unsigned FUNC3 Store OPs are not supported.")); } break; default: break; } break; case Cycle.Write: switch (pipeWriteMode) { case PIPELINE_WRITE_MODE.NOP: break; case PIPELINE_WRITE_MODE.WRITE_REGISTER: registers.setR((Register)pipeWriteAddress, pipeWriteData); break; case PIPELINE_WRITE_MODE.WRITE_MEMORY: switch (pipeWriteByteCount) { case 1: bus.op = MainBus.OP.st_1b; break; case 2: bus.op = MainBus.OP.st_2b; break; case 4: bus.op = MainBus.OP.st_4b; break; case 8: bus.op = MainBus.OP.st_8b; break; default: break; } bus.address = pipeWriteAddress; bus.data = pipeWriteData; break; case PIPELINE_WRITE_MODE.LOAD_TO_REGISTER: if (pipeWriteData == 1) //Should Sign Extend { switch (pipeWriteByteCount) { case 1: registers.setR((Register)pipeWriteAddress, (ulong)(((short)(ushort)bus.data << 8) >> 8)); break; case 2: registers.setR((Register)pipeWriteAddress, (ulong)(long)(short)(ushort)bus.data); break; case 4: registers.setR((Register)pipeWriteAddress, (ulong)(long)(int)(uint)bus.data); break; case 8: default: registers.setR((Register)pipeWriteAddress, bus.data); break; } } else { registers.setR((Register)pipeWriteAddress, bus.data); } break; default: break; } pipeWriteMode = PIPELINE_WRITE_MODE.NOP; pipeWriteData = 0; pipeWriteAddress = 0; pipeWriteByteCount = 0; break; case Cycle.MovPC: if (currentBranchPending) { registers.setR(Register.PC, currentBranch); } else { registers.setR(Register.PC, currentPC + 0x04u); } break; case Cycle.Halt: break; default: break; } }
public Instruction(InstructionType InstructionType, Node Result, Node Argument) { m_InstructionType = InstructionType; m_Result = Result; m_Argument = Argument; }
/// <param name = "destination">Defaulted to program directory. </param> public Instruction(InstructionType instructionType, string source, string destination = "") { iType = instructionType; src = source; dest = destination; }
/// <summary>Creates a line representing an instruction.</summary> public static Instruction Create(InstructionType type, string action, object value) { var line = String.Format("{0} {1} {2}", type, action, value); return Instruction.Parse(line); }
public static bool IsSigned(this InstructionType type) { return(I32ParamInstructionTypes.Contains(type)); }
public Instruction(InstructionType type, List<IInstructionOperand> operands) { Type = type; Operands = operands.AsReadOnly(); }
public Instruction(byte sizeInTable, InstructionType type) { Type = type; SizeInTable = sizeInTable; Size = sizeInTable; }
public Instruction(InstructionType type, Condition? condition) { this.type = type; this.condition = condition; }
/// <summary> /// Someone decided that dictionaries should throw instead of returning null...let's undo that. /// Tries to get a value for the given key. Returns null if it doesn't exist. /// </summary> /// <param name="dictionary">The dictionary.</param> /// <param name="key">They key.</param> /// <returns></returns> public static Action<ExecutionContext, Instruction> Lookup(this IDictionary<InstructionType, Action<ExecutionContext, Instruction>> dictionary, InstructionType key) { Action<ExecutionContext, Instruction> action; dictionary.TryGetValue(key, out action); return action; }
internal void SetInstructions(InstructionType instructionType, Instruction instruction) { if (Instructions.ContainsKey(instructionType)) Instructions[instructionType] = instruction; else Instructions.Add(instructionType, instruction); }
private string ArgumentToString(byte bank, ushort address, InstructionType instType, GBArgument arg) { switch (arg.ArgType) { case GBArgumentType.Bit: return arg.NumArg.ToString(); case GBArgumentType.Byte: return NumberToASMString(arg.NumArg, NumberType.Byte); case GBArgumentType.MemMapWord: { var vName = lc.GetSymbolsByValue(arg.NumArg, true); if (vName.Count != 0) { return "[" + vName[0].Name + "]"; } else { return "[" + NumberToASMString(arg.NumArg, NumberType.Word) + "]"; } } case GBArgumentType.Word: { var vName = lc.GetSymbolsByValue(arg.NumArg, false); if (arg.NumArg < 0x8000 && vName.Count != 0) { return vName[0].Name; } if (instType == InstructionType.ld) { var s = lc.GetSymbolsByValue(arg.NumArg, true); if (s.Count != 0) { return s[0].Name; } } return NumberToASMString(arg.NumArg, NumberType.Word); } case GBArgumentType.MemMapRegisterSingle: return "[" + arg.RegSingleArg.ToString() + "]"; case GBArgumentType.RegisterSingle: return arg.RegSingleArg.ToString(); case GBArgumentType.MemMapRegisterDouble: return "[" + arg.RegDoubleArg.ToString() + "]"; case GBArgumentType.RegisterDouble: return arg.RegDoubleArg.ToString(); case GBArgumentType.Conditional: return arg.CondArg.ToString(); default: return ""; } }
public Instruction(SourceLocation location, InstructionType instructionType, int argument = 0) { SourceLocation = location; InstructionType = instructionType; Argument = argument; }
public OperationCode(string instruction, InstructionType type, string opCode, string aluCode) : this(instruction, type, opCode) { ALUCode = aluCode; }
public int decode(byte[] b) { this.t = InstructionType.InstructionIllegal; if (b.Length < 1) return 0; switch ((char)b[0]) { case 'R': this.t = InstructionType.InstructionRestart; return 1; case 'B': this.t = InstructionType.InstructionTransition; this.r = this.g = this.b = 0; this.value = 0; return 1; case 'D': if (b.Length < 2) return 0; this.t = InstructionType.InstructionSetDisplay; this.value = (int)b[1]; return 2; case 'C': if (b.Length < 4) return 0; this.t = InstructionType.InstructionTransition; this.r = (int)b[1]; this.g = (int)b[2]; this.b = (int)b[3]; this.value = 0; return 4; case 'T': if (b.Length < 5) return 0; this.t = InstructionType.InstructionTransition; this.r = (int)b[1]; this.g = (int)b[2]; this.b = (int)b[3]; this.value = (int)b[4]; return 5; case 't': if (b.Length < 6) return 0; this.t = InstructionType.InstructionTransition; this.r = (int)b[1]; this.g = (int)b[2]; this.b = (int)b[3]; this.value = ((int)b[4]) << 8; this.value |= (int)b[5]; return 6; case 'w': if (b.Length < 2) return 0; this.t = InstructionType.InstructionWait; this.value = DelayTable.indexToDelay(b[1]); return 2; case 'x': if (b.Length < 5) return 0; this.t = InstructionType.InstructionTransition; this.r = (int)b[1]; this.g = (int)b[2]; this.b = (int)b[3]; this.value = DelayTable.indexToDelay(b[4]); return 5; default: return 0; } }
public Instruction(InstructionType type, params IInstructionOperand[] operands) { Type = type; Operands = new ReadOnlyCollection<IInstructionOperand>(operands); }
public Instruction(InstructionType type, string op1, string op2) { this.cmd = type; this.src = op1; this.dst = op2; }
public Instruction(InstructionType t = InstructionType.InstructionIllegal) { this.t = t; }
public void AddInstruction(InstructionType instructionType, Condition? condition = null) { instructions.Add(new Instruction(instructionType, condition)); }
internal Instruction ByType(InstructionType switchType) { return Instructions.FirstOrDefault(x => x.InstructionType == switchType); }
/// <summary> /// Helper method for dealing with 12 Bit Signed Integer values and converting them to .NET C# Int32 values /// </summary> /// <param name="coding">the uint coding (i.e a I-Type 12 Bit signed int)</param> /// <param name="bitLength">the bit length (12 for an I-Type)</param> /// <returns>a Int32 .NET representation of the coding</returns> public static int GetSignedInteger(int coding, InstructionType type) { var bitLength = GetBitLength(type); return(GetSignedInteger(coding, bitLength)); }
public AssemblyInstruction(String mnemonic, ushort instructionCode, InstructionType type) { _mnemonic = mnemonic; _instructionCode = instructionCode; _type = type; }
public Instruction() { this.inst = InstructionType.UNKNOWN; this.detail = ""; }
public Instruction(InstructionType InstructionType) : this(InstructionType, null, null) { }
public Code(string symb) { this.symb = symb; this.instructionType = InstructionType.A_SYMBOL; }
internal Instruction(InstructionType type, byte size, byte mode) { this.type = type; this.size = size; this.mode = mode; }
public Instruction() { InstructionType = InstructionType.Double; }
public Instruction(InstructionType type, Colour?colour) { this.Type = type; this.Colour = colour; }
internal bool DoesntContainsInstruction(InstructionType switchType) { return ByType(switchType) == null; }
public Instruction(InstructionType type, string detail) { this.inst = type; this.detail = detail; }
public void ReadLine(string line, LineEnding lineEnding, ref ConfigIniSection currentSection) { if (line == null) { return; } if (string.IsNullOrWhiteSpace(line)) { var lastToken = currentSection.GetLastToken(); var whitespace = lastToken as WhitespaceToken; if (whitespace == null) { whitespace = new WhitespaceToken(); currentSection.Tokens.Add(whitespace); } whitespace.AddLine(line, lineEnding); return; } string endTrimmedLine = line.TrimEnd(); string lineWasteSuffix = line.Substring(endTrimmedLine.Length); string trimmedLine = endTrimmedLine.TrimStart(); string lineWastePrefix = line.Substring(0, endTrimmedLine.Length - trimmedLine.Length); if (trimmedLine.StartsWith(";")) { var lastToken = currentSection.GetLastToken(); var comment = lastToken as CommentToken; if (comment == null) { comment = new CommentToken(); currentSection.Tokens.Add(comment); } comment.AddLine(line, lineEnding); return; } if (trimmedLine.StartsWith("[") && trimmedLine.EndsWith("]")) { string sectionName = trimmedLine.Substring(1, trimmedLine.Length - 2); currentSection = new ConfigIniSection(sectionName); currentSection.LineWastePrefix = String.IsNullOrEmpty(lineWastePrefix) ? null : lineWastePrefix; currentSection.LineWasteSuffix = String.IsNullOrEmpty(lineWasteSuffix) ? null : lineWasteSuffix; currentSection.LineEnding = lineEnding; Sections.Add(currentSection); return; } if (line.StartsWith("!")) { var key = line.Substring(1); if (!String.IsNullOrWhiteSpace(key)) { var instruction = new InstructionToken(InstructionType.RemoveAll, key, lineEnding); currentSection.Tokens.Add(instruction); return; } } int separatorIdx = line.IndexOf("="); if (separatorIdx >= 0) { string key = line.Substring(0, separatorIdx); string value = line.Substring(separatorIdx + 1); InstructionType type = InstructionType.Set; if (key.Length > 0) { switch (key[0]) { case '+': type = InstructionType.Add; key = key.Substring(1); break; case '.': type = InstructionType.AddForce; key = key.Substring(1); break; case '-': type = InstructionType.Remove; key = key.Substring(1); break; default: break; } } var instruction = new InstructionToken(type, key, value, lineEnding); currentSection.Tokens.Add(instruction); return; } var text = new TextToken(); text.Text = line; text.LineEnding = lineEnding; currentSection.Tokens.Add(text); return; }
public Code(int addr) { this.addr = addr; this.instructionType = InstructionType.A_REGISTER; }
public InstructionArgs(InstructionType type) { Arguments = new List <object>(); Type = type; }
public Instruction(Instruction instruction, InstructionType newType) { this.Type = newType; this.Value = instruction.Value; }
public Instruction(InstructionType type) : this(type, 0) { }
public Instruction(string name) { Name = name; InstructionType = InstructionType.Double; }
public Instruction( string name, uint opcode, uint mask, AddressBits addressBits, InstructionType type ) { this.Name = name; this.Opcode = opcode; this.Mask = mask; this.AddressBits = addressBits; this.Type = type; }
private static InstructionInfo ID(String Name, String BinaryEncoding, String AsmEncoding, AddressType AddressType, InstructionType InstructionType) { return new InstructionInfo() { Name = Name, BinaryEncoding = BinaryEncoding, AsmEncoding = AsmEncoding, AddressType = AddressType, InstructionType = InstructionType }; }
public OperationCode(string instruction, InstructionType type, string opCode) { Instruction = instruction; InstructionType = type; OpCode = opCode; }
public GameInstruction() { this.type = InstructionType.Nothing; }
public Instruction(InstructionType type) { this.type = type; }
void Decode() { if (currentInstruction.Length == 7) { currentInstruction = "0" + currentInstruction; } string currentInstructionCopy = currentInstruction; string firstTwoHexChars = currentInstructionCopy.Substring(0, 2); currentInstructionCopy = currentInstructionCopy.Substring(2, 6); currentInstruction = currentInstructionCopy; switch (firstTwoHexChars) { case "C0"://RD currentInstructionOpType = InstructionType.IO; currentInstructionOp = Instruction.RD; break; case "C1"://WR currentInstructionOpType = InstructionType.IO; currentInstructionOp = Instruction.WR; break; case "42"://ST currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.ST; break; case "43"://LW currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.LW; break; case "04"://MOV currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.MOV; break; case "05"://ADD currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.ADD; break; case "06"://SUB currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.SUB; break; case "07"://MUL currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.MUL; break; case "08"://DIV currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.DIV; break; case "09"://AND currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.AND; break; case "0A"://OR currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.OR; break; case "4B"://MOVI currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.MOVI; break; case "4C"://ADDI currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.ADDI; break; case "4D"://MULI currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.MULI; break; case "4E"://DIVI currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.DIVI; break; case "4F"://LDI currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.LDI; break; case "10"://SLT currentInstructionOpType = InstructionType.R; currentInstructionOp = Instruction.SLT; break; case "51"://SLTI currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.SLTI; break; case "92"://HLT currentInstructionOpType = InstructionType.J; currentInstructionOp = Instruction.HLT; break; case "13"://NOP currentInstructionOpType = InstructionType.NOP; currentInstructionOp = Instruction.NOP; break; case "94"://JMP currentInstructionOpType = InstructionType.J; currentInstructionOp = Instruction.JMP; break; case "55"://BEQ currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.BEQ; break; case "56"://BNE currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.BNE; break; case "57"://BEZ currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.BEZ; break; case "58"://BNZ currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.BNZ; break; case "59"://BGZ currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.BGZ; break; case "5A"://BLZ currentInstructionOpType = InstructionType.I; currentInstructionOp = Instruction.BLZ; break; default: Console.WriteLine("oops!"); break; } switch (currentInstructionOpType) { case InstructionType.R: sreg1 = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(0, 1)); sreg2 = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(1, 1)); dreg = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(2, 1)); break; case InstructionType.IO: cpuPCB.IoCount++; if (currentInstructionOp == Instruction.RD) { reg1 = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(0, 1)); reg2 = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(1, 1)); address = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(2, 4)) / 4; } else if (currentInstructionOp == Instruction.WR) { reg1 = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(0, 1)); reg2 = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(1, 1)); address = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(2, 4)) / 4; } break; case InstructionType.I: breg = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(0, 1)); dreg = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(1, 1)); address = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(2, 4)); break; case InstructionType.J: address = SystemCaller.ConvertHexstringToUInt(currentInstructionCopy.Substring(0, 6)) / 4; break; case InstructionType.NOP: break; } }
public Instruction(InstructionType type, int parameter) { Type = type; Parameter = parameter; }
public Instruction(InstructionType instructionType, object data) : this(instructionType) { this.data = data; }