use crate::*;
const ALIGNED_ADDR: u64 = 0x3000;
const ALIGNED_ADDR2: u64 = 0x3100;
fn float_bits(val: f32) -> [u8; 4] {
val.to_le_bytes()
}
#[test]
fn test_cmpss_eq_equal_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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
let data = float_bits(5.0);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &data);
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_eq_different_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_eq_positive_and_negative_zero() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(0.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(-0.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_eq_same_denormal() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
let denormal = f32::from_bits(1);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(denormal));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_true() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_false() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(3.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_equal_false() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(5.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_negative_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(-5.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(-2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_le_less() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x02, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.5));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_le_equal() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x02, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(3.14));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_le_greater() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x02, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(5.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_le_with_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x02, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(0.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(0.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_unord_ordered() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x03, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_unord_same_value() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x03, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(7.5));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_neq_different() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x04, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(3.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_neq_equal() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x04, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_neq_tiny_difference() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x04, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(1.0000001));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nlt_greater() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x05, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(5.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nlt_equal() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x05, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(4.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nlt_less() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x05, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(3.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nle_greater() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x06, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(6.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nle_equal() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x06, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.5));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nle_less_or_equal() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x06, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(3.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nle_negative_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x06, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(-1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(-3.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_ord_both_ordered() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x07, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(10.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(20.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_ord_same_value() {
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(&[
0x0f, 0x28, 0x00, 0xf3, 0x0f, 0xc2, 0xc0, 0x07, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(99.99));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_ord_very_small_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x07, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1e-10));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2e-10));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_ord_large_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x07, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1e10));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2e10));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_eq_infinities() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(f32::INFINITY));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(f32::INFINITY));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_infinity() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(f32::INFINITY));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_negative_infinity() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(f32::NEG_INFINITY));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(1.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_neq_large_numbers() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x04, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1e30));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(2e30));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_le_mixed_signs() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x02, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(-100.5));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(100.5));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nlt_large_positive_numbers() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x05, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(1e20));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(1e19));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_nle_zero_comparison() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x06, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(0.1));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(0.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_ord_both_negative_zero() {
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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x07, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(-0.0));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(-0.0));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_eq_mixed_special_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x00, 0xf4, ]);
emu.load_code_bytes(&full_code);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(f32::NEG_INFINITY));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(f32::INFINITY));
emu.run(None).unwrap();
}
#[test]
fn test_cmpss_lt_with_denormal_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(&[
0x0f, 0x28, 0x00, 0x0f, 0x28, 0x0b, 0xf3, 0x0f, 0xc2, 0xc1, 0x01, 0xf4, ]);
emu.load_code_bytes(&full_code);
let denormal = f32::from_bits(1);
emu.maps.write_bytes_slice(ALIGNED_ADDR, &float_bits(denormal));
emu.maps.write_bytes_slice(ALIGNED_ADDR2, &float_bits(1.0));
emu.run(None).unwrap();
}