use crate::*;
const ALIGNED_ADDR: u64 = 0x3000;
#[test]
fn test_pcmpestri_equal_any_basic() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00, 0x66, 0x0f, 0x6f, 0x48, 0x10, 0xb8, 0x03, 0x00, 0x00, 0x00, 0xba, 0x05, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x62, 0x79, 0x63, 0x7a, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_zero_length_first() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x00, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_zero_length_second() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x03, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_full_16_bytes() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x10, 0x00, 0x00, 0x00, 0xba, 0x10, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61]; let data2: [u8; 16] = [0x62, 0x61, 0x62, 0x61, 0x62, 0x61, 0x62, 0x61,
0x62, 0x61, 0x62, 0x61, 0x62, 0x61, 0x62, 0x61];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_partial_lengths() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x04, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x99, 0x99, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x62, 0x79, 0x61, 0x99, 0x99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_uwords() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x01,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x34, 0x12, 0x78, 0x56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_sword_length_8() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x08, 0x00, 0x00, 0x00, 0xba, 0x08, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x03,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x34, 0x12, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x00,
0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00];
let data2: [u8; 16] = [0x56, 0x78, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x00,
0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_ranges() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x08, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x04,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x7a, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x31, 0x32, 0x33, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_ranges_multiple() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x04, 0x00, 0x00, 0x00, 0xba, 0x0a, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x04,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x7a, 0x30, 0x39, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x54, 0x65, 0x73, 0x74, 0x31, 0x32, 0x33, 0x21, 0x40, 0x23, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_equal_each() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x04, 0x00, 0x00, 0x00, 0xba, 0x04, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x08,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0x64, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x62, 0x58, 0x64, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_equal_each_different_lengths() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x05, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x08,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0x64, 0x65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x62, 0x63, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_equal_ordered_substring() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x06, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x0c,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x63, 0x64, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_equal_ordered_no_match() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x03, 0x00, 0x00, 0x00, 0xba, 0x06, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x0c,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x78, 0x79, 0x7a, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_negative_polarity() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x05, 0x00, 0x00, 0x00, 0xba, 0x05, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x10,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x65, 0x69, 0x6f, 0x75, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x62, 0x63, 0x64, 0x66, 0x67, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_negative_ranges() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x06, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x14,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x30, 0x39, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x31, 0x32, 0x33, 0x61, 0x62, 0x63, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_msb() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x07, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x20,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x61, 0x78, 0x62, 0x78, 0x61, 0x78, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm8_xmm9() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x00, 0x66, 0x44, 0x0f, 0x6f, 0x48, 0x10, 0xb8, 0x03, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x45, 0x0f, 0x3a, 0x61, 0xc1, 0x00, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x62, 0x79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm10_xmm11() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x10, 0x66, 0x44, 0x0f, 0x6f, 0x58, 0x10, 0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x04, 0x00, 0x00, 0x00, 0x66, 0x45, 0x0f, 0x3a, 0x61, 0xd3, 0x0c, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x61, 0x62, 0x79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm12_xmm13() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x20, 0x66, 0x44, 0x0f, 0x6f, 0x68, 0x10, 0xb8, 0x02, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x45, 0x0f, 0x3a, 0x61, 0xe5, 0x04, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x30, 0x39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x35, 0x62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm14_xmm15() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x30, 0x66, 0x44, 0x0f, 0x6f, 0x78, 0x10, 0xb8, 0x03, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x45, 0x0f, 0x3a, 0x61, 0xf7, 0x08, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_memory_operand() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00, 0xb8, 0x03, 0x00, 0x00, 0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0x40, 0x10, 0x00, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x62, 0x79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm2_xmm3() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x10, 0x66, 0x0f, 0x6f, 0x58, 0x10, 0xb8, 0x02, 0x00, 0x00, 0x00,
0xba, 0x02, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xd3, 0x00, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm4_xmm5() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x20, 0x66, 0x0f, 0x6f, 0x68, 0x10, 0xb8, 0x03, 0x00, 0x00, 0x00,
0xba, 0x03, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xe5, 0x08, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_xmm6_xmm7() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x30, 0x66, 0x0f, 0x6f, 0x78, 0x10, 0xb8, 0x02, 0x00, 0x00, 0x00,
0xba, 0x04, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xf7, 0x0c, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x61, 0x62, 0x79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_max_byte_length() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x10, 0x00, 0x00, 0x00, 0xba, 0x10, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70];
let data2: [u8; 16] = [0x71, 0x62, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x61, 0x62, 0x63, 0x64, 0x65];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_max_word_length() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x08, 0x00, 0x00, 0x00, 0xba, 0x08, 0x00, 0x00, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x01,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00,
0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00];
let data2: [u8; 16] = [0x09, 0x00, 0x02, 0x00, 0x0a, 0x00, 0x0b, 0x00,
0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0f, 0x00];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_sequence_operations() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x03, 0x00, 0x00, 0x00,
0xba, 0x03, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x08, 0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x0c, 0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let data2: [u8; 16] = [0x78, 0x62, 0x79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pcmpestri_varying_lengths() {
let mut emu = emu64();
let code = [0x48, 0xb8];
let mut full_code = code.to_vec();
full_code.extend_from_slice(&ALIGNED_ADDR.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x48, 0x10,
0xb8, 0x01, 0x00, 0x00, 0x00, 0xba, 0x01, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xb8, 0x05, 0x00, 0x00, 0x00, 0xba, 0x05, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xb8, 0x10, 0x00, 0x00, 0x00, 0xba, 0x10, 0x00, 0x00, 0x00,
0x66, 0x0f, 0x3a, 0x61, 0xc1, 0x00,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1: [u8; 16] = [0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70];
let data2: [u8; 16] = [0x71, 0x62, 0x72, 0x63, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7a, 0x61, 0x62, 0x63, 0x64];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR + 0x10, &data2);
emu.run(None).unwrap();
}