use crate::color;
use crate::emu::Emu;
use iced_x86::Instruction;

pub fn execute(emu: &mut Emu, ins: &Instruction, instruction_sz: usize, _rep_step: bool) -> bool {
    emu.show_instruction(color!("Green"), ins);

    let value0 = match emu.get_operand_xmm_value_128(ins, 0, true) {
        Some(v) => v,
        None => {
            log::info!("error getting xmm value0");
            return false;
        }
    };
    let value1 = match emu.get_operand_xmm_value_128(ins, 1, true) {
        Some(v) => v,
        None => {
            log::info!("error getting xmm value1");
            return false;
        }
    };

    let a: u128 = (value0 & 0xffffffff_ffffffff) ^ (value1 & 0xffffffff_ffffffff);
    let b: u128 = (value0 & 0xffffffff_ffffffff_00000000_00000000)
        ^ (value1 & 0xffffffff_ffffffff_00000000_00000000);
    let result: u128 = a | b;

    emu.set_operand_xmm_value_128(ins, 0, result);
    true
}
