public static Op Read(Byte[] bytes) { if (bytes.Length < 1) { throw new Exception("Cannot read empty bytes"); } Instr instr = (Instr)bytes[0]; int length; if (!OpcodeGen.Encodings.ContainsKey(instr)) { throw new Exception("Invalid opcode {X:0}".Fmt(instr)); } length = OpcodeGen.EncodingSize[OpcodeGen.Encodings[instr]]; if (bytes.Length - 1 < length) { throw new Exception("Opcode data encoding is smaller than given."); } Array.Copy(bytes, 1, Buffer, 0, length); for (int i = length; i < Buffer.Length; ++i) { Buffer[i] = 0; } return(Op.CreateOp(instr, BitConverter.ToInt32(Buffer, 0))); }