pub fn decode(raw_instruction: RawInstruction) -> Instruction {
        // This one is pretty common
        if raw_instruction == 0 {return Instruction::Nop};
        let opcode = raw_instruction >> 12;  // 4 most sig. bits
        match opcode {
            0x0 | 0x1 | 0x2 => {
                if raw_instruction & 0xFC00 == 0 {
                    decode_misc_mult_op(raw_instruction)
                } else {
                    decode_two_reg_op(raw_instruction)
                }   
            },
            0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0xE => {
                decode_reg_const_op(raw_instruction)
            },
            0x8 | 0xA => { // LDD / STD
                decode_load_store(raw_instruction)
            },
            0x9 => { // Misc operations
                decode_misc_op(raw_instruction)
            },
            0xB => {
                decode_in_out(raw_instruction)
            },
            0xC | 0xD => {
                let is_call = opcode == 0xD;
                let offset = raw_instruction & 0xFFF;
                Instruction::CallJmp { is_call, relative: true, address: offset }
            },
            0xF => {
                decode_branch_skip_status_op(raw_instruction)
            },
            _ => {
                unreachable!()
            }
        }
    }
/// Decodes a 2-byte instruction into a struct with decoded operands
Decodes a 2-byte instruction into a struct with decoded operands
Decodes a 2 - byte instruction into a struct with decoded operands
pub fn decode(raw_instruction: RawInstruction) -> Instruction {
        // This one is pretty common
        if raw_instruction == 0 {return Instruction::Nop};
        let opcode = raw_instruction >> 12;  // 4 most sig. bits
        match opcode {
            0x0 | 0x1 | 0x2 => {
                if raw_instruction & 0xFC00 == 0 {
                    decode_misc_mult_op(raw_instruction)
                } else {
                    decode_two_reg_op(raw_instruction)
                }   
            },
            0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0xE => {
                decode_reg_const_op(raw_instruction)
            },
            0x8 | 0xA => { // LDD / STD
                decode_load_store(raw_instruction)
            },
            0x9 => { // Misc operations
                decode_misc_op(raw_instruction)
            },
            0xB => {
                decode_in_out(raw_instruction)
            },
            0xC | 0xD => {
                let is_call = opcode == 0xD;
                let offset = raw_instruction & 0xFFF;
                Instruction::CallJmp { is_call, relative: true, address: offset }
            },
            0xF => {
                decode_branch_skip_status_op(raw_instruction)
            },
            _ => {
                unreachable!()
            }
        }
    }
pub fn decode ( raw_instruction : RawInstruction ) -> Instruction { // This one is pretty common if raw_instruction == 0 { return Instruction :: Nop } ; let opcode = raw_instruction >> 12 ; // 4 most sig. bits match opcode { 0x0 | 0x1 | 0x2 => { if raw_instruction & 0xFC00 == 0 { decode_misc_mult_op ( raw_instruction ) } else { decode_two_reg_op ( raw_instruction ) } } , 0x3 | 0x4 | 0x5 | 0x6 | 0x7 | 0xE => { decode_reg_const_op ( raw_instruction ) } , 0x8 | 0xA => { // LDD / STD decode_load_store ( raw_instruction ) } , 0x9 => { // Misc operations decode_misc_op ( raw_instruction ) } , 0xB => { decode_in_out ( raw_instruction ) } , 0xC | 0xD => { let is_call = opcode == 0xD ; let offset = raw_instruction & 0xFFF ; Instruction :: CallJmp { is_call , relative : true , address : offset } } , 0xF => { decode_branch_skip_status_op ( raw_instruction ) } , _ => { unreachable ! ( ) } } }
Decodes a 2-byte instruction into a struct with decoded operands
Decodes a 2 - byte instruction into a struct with decoded operands
raw_instruction
RawInstruction
raw_instruction
RawInstruction