private string buildHexValue(Opcode opcode, string operand) { var hasOperand = new Opcode[] { Opcode.ADD, Opcode.STORE, Opcode.LOAD, Opcode.DEC, Opcode.HEX, Opcode.ADDI, Opcode.JUMP, Opcode.SKIPCOND, Opcode.JNS, Opcode.JUMPI, Opcode.STOREI, Opcode.LOADI, Opcode.SUBT }; if (hasOperand.Contains(opcode)) { if (opcode == Opcode.DEC) { return(int.Parse(operand).ToString("X4")); } else if (opcode == Opcode.HEX) { return(int.Parse(operand, System.Globalization.NumberStyles.HexNumber).ToString("X4")); } else if (symbolTable.ContainsKey(operand)) { return(((int)opcode).ToString("X1") + symbolTable[operand]); } else { return(((int)opcode).ToString("X1") + operand); } } else { return(((int)opcode).ToString("X1") + "000"); } }