//returns the bytes for the opcode in the specified mode public byte[] GetBinary(OperandMode om) { if (hexValues.ContainsKey(om)) { return(hexValues[om]); } throw new Exception("Unable to get binary for opcode " + Name + " in mode " + om.ToString()); }
/// <summary> /// Adds a mode to the opcode def table /// </summary> /// <param name="opcode"></param> /// <param name="mode"></param> /// <param name="byte1"></param> /// <param name="byte2"></param> /// <param name="byte3"></param> private static void AddMode(string opcode, OperandMode mode, byte byte1, byte byte2 = 0, byte byte3 = 0) { byte[] codes; if (byte3 != 0 && byte2 != 0) { codes = new byte[] { byte1, byte2, byte3 }; } else if (byte3 == 0 && byte2 != 0) { codes = new byte[] { byte1, byte2 }; } else { codes = new byte[] { byte1 }; } OpCodeDef op = opcodes.Find( (o) => { return(o.Name == opcode); } ); if (op == null) { throw new Exception("Opcode " + opcode + " not found while trying to add mode" + mode.ToString()); } op.AddMode(mode, codes); }