public DataProcessing(string instruction) { string[] insPieces = instruction.Split(" ", 2); string opcode = Literals.OpCodes[insPieces[0].ToUpper()]; string s = "1"; string I = "0"; OperationType type = Literals.GetOperation(insPieces[0].ToUpper()); string rd = "r15", rn = "r15", rs = "r15", imm = "00000000"; //Compare is weird because it doesn't have an rd, add it anyways because it isn't used. if (opcode.Equals("1000")) { insPieces[1] = "r15," + insPieces[1]; } string[] registers = insPieces[1].Split(','); if (type.HasFlag(OperationType.Rd)) { rd = registers[0]; } if (type.HasFlag(OperationType.Rn)) { if (Int32.TryParse(registers[1].ToString(), out int immInt)) { rn = "r15"; imm = Literals.IntToBinaryString(immInt); I = "1"; } else { rn = registers[1]; } } if (type.HasFlag(OperationType.Rs) || type.HasFlag(OperationType.Imm)) { if (!type.HasFlag(OperationType.Rs) && registers.Length == 2) { //Do nothing, we already did it in the last step } else if (Int32.TryParse(registers[2].ToString(), out int immInt)) { rs = "r15"; imm = Literals.IntToBinaryString(immInt); I = "1"; } else { rs = registers[2]; } } _operation = Prefix + I + opcode + s + Literals.Registers[rn] + Literals.Registers[rd] + Literals.Registers[rs] + imm; }