pub fn resolve(cpu: &mut DCPU16, instruction: Instruction) -> Self {
        let (raw_instruction, instruction_word, raw_1st, raw_2nd) = instruction.unpack();

        // Get the "a" and "b" value definitions from the original instruction.
        let (a, b) = instruction_word.unpack();

        // Most instructions have two operands.
        if let Some(b) = b {
            // The "a" value always exists, however it may use an "inline" value, e.g. a
            // register or default literal. In that case the "first operand" provided to the
            // instruction really belongs to the second value, i.e., "b".
            if a.has_extra_words() {
                let (lhs_arg, lhs) = cpu.resolve_argument(a, raw_1st);
                let (rhs_arg, rhs) = cpu.resolve_argument(b, raw_2nd);

                InstructionWithOperands {
                    raw_instruction,
                    instruction: instruction_word,
                    a: ResolvedValue {
                        argument_definition: a,
                        argument: lhs_arg,
                        resolved_value: lhs
                    },
                    b: Some(ResolvedValue {
                        argument_definition: b,
                        argument: rhs_arg,
                        resolved_value: rhs
                    }),
                }
            }
            else {
                // Since we know that the "a" value has no extra operand, we pass it to the second.
                let (lhs_arg, lhs) = cpu.resolve_argument(a, None);
                let (rhs_arg, rhs) = cpu.resolve_argument(b, raw_1st);
                assert!(raw_2nd.is_none());

                InstructionWithOperands {
                    raw_instruction,
                    instruction: instruction_word,
                    a: ResolvedValue {
                        argument_definition: a,
                        argument: lhs_arg,
                        resolved_value: lhs
                    },
                    b: Some(ResolvedValue {
                        argument_definition: b,
                        argument: rhs_arg,
                        resolved_value: rhs
                    }),
                }
            }
        }
        else {
            // A simpler version of above, we just need to anticipate the first operand.
            let (lhs_arg, lhs) = cpu.resolve_argument(a, raw_1st);
            assert!(a.has_extra_words() && raw_1st.is_some() || !a.has_extra_words());
            assert!(raw_2nd.is_none());

            InstructionWithOperands {
                raw_instruction,
                instruction: instruction_word,
                a: ResolvedValue {
                    argument_definition: a,
                    argument: lhs_arg,
                    resolved_value: lhs
                },
                b: None
            }
        }
    }
/// Resolves the values for each argument of the instruction word.
Resolves the values for each argument of the instruction word.
Resolves the values for each argument of the instruction word .
pub fn resolve(cpu: &mut DCPU16, instruction: Instruction) -> Self {
        let (raw_instruction, instruction_word, raw_1st, raw_2nd) = instruction.unpack();
        // Get the "a" and "b" value definitions from the original instruction.
        let (a, b) = instruction_word.unpack();
        // Most instructions have two operands.
        if let Some(b) = b {
            // The "a" value always exists, however it may use an "inline" value, e.g. a
            // register or default literal. In that case the "first operand" provided to the
            // instruction really belongs to the second value, i.e., "b".
            if a.has_extra_words() {
                let (lhs_arg, lhs) = cpu.resolve_argument(a, raw_1st);
                let (rhs_arg, rhs) = cpu.resolve_argument(b, raw_2nd);
                InstructionWithOperands {
                    raw_instruction,
                    instruction: instruction_word,
                    a: ResolvedValue {
                        argument_definition: a,
                        argument: lhs_arg,
                        resolved_value: lhs
                    },
                    b: Some(ResolvedValue {
                        argument_definition: b,
                        argument: rhs_arg,
                        resolved_value: rhs
                    }),
                }
            }
            else {
                // Since we know that the "a" value has no extra operand, we pass it to the second.
                let (lhs_arg, lhs) = cpu.resolve_argument(a, None);
                let (rhs_arg, rhs) = cpu.resolve_argument(b, raw_1st);
                assert!(raw_2nd.is_none());
                InstructionWithOperands {
                    raw_instruction,
                    instruction: instruction_word,
                    a: ResolvedValue {
                        argument_definition: a,
                        argument: lhs_arg,
                        resolved_value: lhs
                    },
                    b: Some(ResolvedValue {
                        argument_definition: b,
                        argument: rhs_arg,
                        resolved_value: rhs
                    }),
                }
            }
        }
        else {
            // A simpler version of above, we just need to anticipate the first operand.
            let (lhs_arg, lhs) = cpu.resolve_argument(a, raw_1st);
            assert!(a.has_extra_words() && raw_1st.is_some() || !a.has_extra_words());
            assert!(raw_2nd.is_none());
            InstructionWithOperands {
                raw_instruction,
                instruction: instruction_word,
                a: ResolvedValue {
                    argument_definition: a,
                    argument: lhs_arg,
                    resolved_value: lhs
                },
                b: None
            }
        }
    }
pub fn resolve ( cpu : & mut DCPU16 , instruction : Instruction ) -> Self { let ( raw_instruction , instruction_word , raw_1st , raw_2nd ) = instruction . unpack ( ) ; // Get the "a" and "b" value definitions from the original instruction. let ( a , b ) = instruction_word . unpack ( ) ; // Most instructions have two operands. if let Some ( b ) = b { // The "a" value always exists, however it may use an "inline" value, e.g. a // register or default literal. In that case the "first operand" provided to the // instruction really belongs to the second value, i.e., "b". if a . has_extra_words ( ) { let ( lhs_arg , lhs ) = cpu . resolve_argument ( a , raw_1st ) ; let ( rhs_arg , rhs ) = cpu . resolve_argument ( b , raw_2nd ) ; InstructionWithOperands { raw_instruction , instruction : instruction_word , a : ResolvedValue { argument_definition : a , argument : lhs_arg , resolved_value : lhs } , b : Some ( ResolvedValue { argument_definition : b , argument : rhs_arg , resolved_value : rhs } ) , } } else { // Since we know that the "a" value has no extra operand, we pass it to the second. let ( lhs_arg , lhs ) = cpu . resolve_argument ( a , None ) ; let ( rhs_arg , rhs ) = cpu . resolve_argument ( b , raw_1st ) ; assert ! ( raw_2nd is_none ( ) ) ; InstructionWithOperands { raw_instruction , instruction : instruction_word , a : ResolvedValue { argument_definition : a , argument : lhs_arg , resolved_value : lhs } , b : Some ( ResolvedValue { argument_definition : b , argument : rhs_arg , resolved_value : rhs } ) , } } } else { // A simpler version of above, we just need to anticipate the first operand. let ( lhs_arg , lhs ) = cpu . resolve_argument ( a , raw_1st ) ; assert ! ( a has_extra_words ( ) raw_1st is_some ( ) a has_extra_words ( ) ) ; assert ! ( raw_2nd is_none ( ) ) ; InstructionWithOperands { raw_instruction , instruction : instruction_word , a : ResolvedValue { argument_definition : a , argument : lhs_arg , resolved_value : lhs } , b : None } } }
Resolves the values for each argument of the instruction word.
Resolves the values for each argument of the instruction word .
cpu
&mut DCPU16
instruction
Instruction