pub fn from_raw(raw: &RawInstruction) -> Instruction {
        use self::Instruction::*;

        match raw.n_high().bits {
            0x0 => {
                match raw.k() {
                    0xE0 => Clear,
                    0xEE => Return,
                    _ => Sys(raw.addr())
                }
            },
            0x1 => Jump(raw.addr()),
            0x2 => Call(raw.addr()),
            0x3 => SkipEqualK(raw.x(), raw.k()),
            0x4 => SkipNotEqualK(raw.x(), raw.k()),
            0x5 => SkipEqual(raw.x(), raw.y()),
            0x6 => SetK(raw.x(), raw.k()),
            0x7 => AddK(raw.x(), raw.k()),
            0x8 => {
                match raw.n_low().bits {
                    0x0 => Set(raw.x(), raw.y()),
                    0x1 => Or(raw.x(), raw.y()),
                    0x2 => And(raw.x(), raw.y()),
                    0x3 => XOr(raw.x(), raw.y()),
                    0x4 => Add(raw.x(), raw.y()),
                    0x5 => Sub(raw.x(), raw.y()),
                    0x6 => ShiftRight(raw.x(), raw.y()),
                    0x7 => SubInv(raw.x(), raw.y()),
                    0xE => ShiftLeft(raw.x(), raw.y()),
                    _ => Unknown
                }
            },
            0x9 => SkipNotEqual(raw.x(), raw.y()),
            0xA => LoadI(raw.addr()),
            0xB => LongJump(raw.addr()),
            0xC => Rand(raw.x(), raw.k()),
            0xD => Draw(raw.x(), raw.y(), raw.n_low()),
            0xE => {
                match raw.k() {
                    0x9E => SkipPressed(raw.x()),
                    0xA1 => SkipNotPressed(raw.x()),
                    _ => Unknown,
                }
            },
            0xF => {
                match raw.k() {
                    0x07 => GetTimer(raw.x()),
                    0x0A => WaitKey(raw.x()),
                    0x15 => SetTimer(raw.x()),
                    0x18 => SetSoundTimer(raw.x()),
                    0x1E => AddToI(raw.x()),
                    0x29 => LoadHexGlyph(raw.x()),
                    0x33 => StoreBCD(raw.x()),
                    0x55 => StoreRegisters(raw.x()),
                    0x65 => LoadRegisters(raw.x()),
                    _ => Unknown,
                }
            }
            _ => Unknown
        }
    }
/// Creates a new instruction from raw bits,
/// or `Instruction::Unknown` if no valid match could be found
Creates a new instruction from raw bits,
or `Instruction::Unknown` if no valid match could be found
Creates a new instruction from raw bits or ` Instruction :: Unknown ` if no valid match could be found
pub fn from_raw(raw: &RawInstruction) -> Instruction {
        use self::Instruction::*;
        match raw.n_high().bits {
            0x0 => {
                match raw.k() {
                    0xE0 => Clear,
                    0xEE => Return,
                    _ => Sys(raw.addr())
                }
            },
            0x1 => Jump(raw.addr()),
            0x2 => Call(raw.addr()),
            0x3 => SkipEqualK(raw.x(), raw.k()),
            0x4 => SkipNotEqualK(raw.x(), raw.k()),
            0x5 => SkipEqual(raw.x(), raw.y()),
            0x6 => SetK(raw.x(), raw.k()),
            0x7 => AddK(raw.x(), raw.k()),
            0x8 => {
                match raw.n_low().bits {
                    0x0 => Set(raw.x(), raw.y()),
                    0x1 => Or(raw.x(), raw.y()),
                    0x2 => And(raw.x(), raw.y()),
                    0x3 => XOr(raw.x(), raw.y()),
                    0x4 => Add(raw.x(), raw.y()),
                    0x5 => Sub(raw.x(), raw.y()),
                    0x6 => ShiftRight(raw.x(), raw.y()),
                    0x7 => SubInv(raw.x(), raw.y()),
                    0xE => ShiftLeft(raw.x(), raw.y()),
                    _ => Unknown
                }
            },
            0x9 => SkipNotEqual(raw.x(), raw.y()),
            0xA => LoadI(raw.addr()),
            0xB => LongJump(raw.addr()),
            0xC => Rand(raw.x(), raw.k()),
            0xD => Draw(raw.x(), raw.y(), raw.n_low()),
            0xE => {
                match raw.k() {
                    0x9E => SkipPressed(raw.x()),
                    0xA1 => SkipNotPressed(raw.x()),
                    _ => Unknown,
                }
            },
            0xF => {
                match raw.k() {
                    0x07 => GetTimer(raw.x()),
                    0x0A => WaitKey(raw.x()),
                    0x15 => SetTimer(raw.x()),
                    0x18 => SetSoundTimer(raw.x()),
                    0x1E => AddToI(raw.x()),
                    0x29 => LoadHexGlyph(raw.x()),
                    0x33 => StoreBCD(raw.x()),
                    0x55 => StoreRegisters(raw.x()),
                    0x65 => LoadRegisters(raw.x()),
                    _ => Unknown,
                }
            }
            _ => Unknown
        }
    }
pub fn from_raw ( raw : & RawInstruction ) -> Instruction { use self :: Instruction :: * ; match raw . n_high ( ) . bits { 0x0 => { match raw . k ( ) { 0xE0 => Clear , 0xEE => Return , _ => Sys ( raw . addr ( ) ) } } , 0x1 => Jump ( raw . addr ( ) ) , 0x2 => Call ( raw . addr ( ) ) , 0x3 => SkipEqualK ( raw . x ( ) , raw . k ( ) ) , 0x4 => SkipNotEqualK ( raw . x ( ) , raw . k ( ) ) , 0x5 => SkipEqual ( raw . x ( ) , raw . y ( ) ) , 0x6 => SetK ( raw . x ( ) , raw . k ( ) ) , 0x7 => AddK ( raw . x ( ) , raw . k ( ) ) , 0x8 => { match raw . n_low ( ) . bits { 0x0 => Set ( raw . x ( ) , raw . y ( ) ) , 0x1 => Or ( raw . x ( ) , raw . y ( ) ) , 0x2 => And ( raw . x ( ) , raw . y ( ) ) , 0x3 => XOr ( raw . x ( ) , raw . y ( ) ) , 0x4 => Add ( raw . x ( ) , raw . y ( ) ) , 0x5 => Sub ( raw . x ( ) , raw . y ( ) ) , 0x6 => ShiftRight ( raw . x ( ) , raw . y ( ) ) , 0x7 => SubInv ( raw . x ( ) , raw . y ( ) ) , 0xE => ShiftLeft ( raw . x ( ) , raw . y ( ) ) , _ => Unknown } } , 0x9 => SkipNotEqual ( raw . x ( ) , raw . y ( ) ) , 0xA => LoadI ( raw . addr ( ) ) , 0xB => LongJump ( raw . addr ( ) ) , 0xC => Rand ( raw . x ( ) , raw . k ( ) ) , 0xD => Draw ( raw . x ( ) , raw . y ( ) , raw . n_low ( ) ) , 0xE => { match raw . k ( ) { 0x9E => SkipPressed ( raw . x ( ) ) , 0xA1 => SkipNotPressed ( raw . x ( ) ) , _ => Unknown , } } , 0xF => { match raw . k ( ) { 0x07 => GetTimer ( raw . x ( ) ) , 0x0A => WaitKey ( raw . x ( ) ) , 0x15 => SetTimer ( raw . x ( ) ) , 0x18 => SetSoundTimer ( raw . x ( ) ) , 0x1E => AddToI ( raw . x ( ) ) , 0x29 => LoadHexGlyph ( raw . x ( ) ) , 0x33 => StoreBCD ( raw . x ( ) ) , 0x55 => StoreRegisters ( raw . x ( ) ) , 0x65 => LoadRegisters ( raw . x ( ) ) , _ => Unknown , } } _ => Unknown } }
Creates a new instruction from raw bits,
or `Instruction::Unknown` if no valid match could be found
Creates a new instruction from raw bits or ` Instruction :: Unknown ` if no valid match could be found
raw
&RawInstruction
raw
&RawInstruction