summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-12-06 13:50:27 -0800
committeriximeow <me@iximeow.net>2020-12-06 13:50:27 -0800
commit47a1d9d6fd48229961edf76b789328dc99a19c6c (patch)
tree076a2f4ef2c9f208ea758443947aa2c62785d6a8
parent561c473a826a60fac742e323387ed30933ce85d2 (diff)
fix an off by one in non-temporal hint selection
thank you @The6P4C for finding and reporting!
-rw-r--r--src/lib.rs2
-rw-r--r--tests/test.rs5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 16a9af8..ea850aa 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1249,7 +1249,7 @@ impl fmt::Display for Instruction {
// hint bits of `00` indicate no prefetch hint
if hint != 0 {
f.write_str(
- [".nt1", ".nt2", ".nt3"][hint as usize]
+ [".nt1", ".nt2", ".nt3"][hint as usize - 1]
)?;
}
}
diff --git a/tests/test.rs b/tests/test.rs
index 8f6feb0..114d81d 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -32,6 +32,11 @@ fn test_invalid_instruction() {
let data = [0xe3, 0x80, 0x00, 0x00, 0x00, 0x61, 0xe2, 0x00, 0x00, 0x00, 0x42, 0xc0, 0xe1, 0x80, 0x30, 0x00];
let inst = decoder.decode(data[..].iter().cloned()).unwrap();
assert_eq!(format!("{}", inst), expected);
+
+ let expected = "[MII] purple.nt3; break.i 0x0; break.i 0x0";
+ let data = [0x00, 0x00, 0x00, 0x00, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
+ let inst = decoder.decode(data[..].iter().cloned()).unwrap();
+ assert_eq!(format!("{}", inst), expected);
}
#[test]
fn test_shr_shl_dep_ext() {