use crate::*;
const ALIGNED_ADDR: u64 = 0x3000;
const ALIGNED_ADDR2: u64 = 0x3100;
#[test]
fn test_pmaxsb_all_zeros() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00, 0x66, 0x0f, 0x6f, 0x0b, 0x66, 0x0f, 0x38, 0x3c, 0xc1, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_max_values() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3c, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_mixed_values() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3c, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1 = [0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08];
let data2 = [0x00, 0x08, 0x00, 0x07, 0x00, 0x06, 0x00, 0x05,
0x00, 0x04, 0x00, 0x03, 0x00, 0x02, 0x00, 0x01];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_large_small() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3c, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x20, 0x66, 0x0f, 0x6f, 0x2b, 0x66, 0x0f, 0x38, 0x3c, 0xe5, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x11, 0x11, 0x22, 0x22, 0x33, 0x33, 0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77, 0x88, 0x88]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xEE, 0xEE, 0xDD, 0xDD, 0xCC, 0xCC, 0xBB, 0xBB, 0xAA, 0xAA, 0x99, 0x99, 0x88, 0x88, 0x77, 0x77]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_from_memory() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x38, 0x3c, 0x03, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x10, 0x00, 0x20, 0x00, 0x30, 0x00, 0x40, 0x00, 0x50, 0x00, 0x60, 0x00, 0x70, 0x00, 0x80]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0x0F, 0xFF, 0x1F, 0xFF, 0x2F, 0xFF, 0x3F, 0xFF, 0x4F, 0xFF, 0x5F, 0xFF, 0x6F, 0xFF, 0x7F]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_identical() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3c, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_alternating() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3c, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1 = [0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0xFF,
0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0xFF];
let data2 = [0xFF, 0xFF, 0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00,
0xFF, 0xFF, 0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_all_zeros() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_max_values() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_mixed_values() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1 = [0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04];
let data2 = [0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_large_small() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_xmm1_xmm2() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x08, 0x66, 0x0f, 0x6f, 0x13, 0x66, 0x0f, 0x38, 0x3d, 0xca, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33, 0x33, 0x44, 0x44, 0x44, 0x44]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xEE, 0xEE, 0xEE, 0xEE, 0xDD, 0xDD, 0xDD, 0xDD, 0xCC, 0xCC, 0xCC, 0xCC, 0xBB, 0xBB, 0xBB, 0xBB]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_from_memory() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x38, 0x3d, 0x03, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0xFF, 0x02, 0x00, 0xFF, 0xFF, 0x03, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_identical() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x42, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0x42, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_alternating() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
let data1 = [0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF];
let data2 = [0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00];
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data1);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &data2);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x10, 0x66, 0x44, 0x0f, 0x6f, 0x1b, 0x66, 0x45, 0x0f, 0x38, 0x3c, 0xd3, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0xFF, 0xFE, 0xFF, 0xFD, 0xFF, 0xFC, 0xFF, 0xFB, 0xFF, 0xFA, 0xFF, 0xF9, 0xFF, 0xF8, 0xFF]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x20, 0x66, 0x44, 0x0f, 0x6f, 0x2b, 0x66, 0x45, 0x0f, 0x38, 0x3d, 0xe5, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_xmm8_from_memory() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x00, 0x66, 0x44, 0x0f, 0x38, 0x3c, 0x03, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x10, 0x00, 0x20, 0x00, 0x30, 0x00, 0x40, 0x00, 0x50, 0x00, 0x60, 0x00, 0x70, 0x00, 0x80]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0x0F, 0xFF, 0x1F, 0xFF, 0x2F, 0xFF, 0x3F, 0xFF, 0x4F, 0xFF, 0x5F, 0xFF, 0x6F, 0xFF, 0x7F]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_xmm14_from_memory() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x44, 0x0f, 0x6f, 0x30, 0x66, 0x44, 0x0f, 0x38, 0x3d, 0x33, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0xFF, 0x02, 0x00, 0xFF, 0xFF, 0x03, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_pmaxsd_sequence() {
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, 0x08, 0x66, 0x0f, 0x38, 0x3c, 0xc1, 0x66, 0x0f, 0x38, 0x3d, 0xc1, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_same_register() {
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, 0x38, 0x3c, 0xc0, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_same_register() {
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, 0x38, 0x3d, 0xc0, 0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsb_boundary_values() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3c, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00]);
emu.run(None).unwrap();
}
#[test]
fn test_pmaxsd_boundary_values() {
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(&[0x48, 0xbb]);
full_code.extend_from_slice(&ALIGNED_ADDR2.to_le_bytes());
full_code.extend_from_slice(&[
0x66, 0x0f, 0x6f, 0x00,
0x66, 0x0f, 0x6f, 0x0b,
0x66, 0x0f, 0x38, 0x3d, 0xc1,
0xf4,
]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &[0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF]);
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &[0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00]);
emu.run(None).unwrap();
}