aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2024-03-09 18:00:42 -0800
committeriximeow <me@iximeow.net>2024-03-09 18:00:42 -0800
commit57aa49ef6b0b5cfc040606a4e2b2f2d097d8aee4 (patch)
treed0a4ae01953260be8135b6dc8d61fa373c123412
parent098b030310a2b6dcc778c2e1cc765be2b3b5e95a (diff)
improve msr register decoding
"improve" rather than "fix" as `pstate.0x3` is hardly as useful as `msr uao, #3`. but the "pstate field" that had been decoded before was totally incorrect.
-rw-r--r--src/armv8/a64.rs6
-rw-r--r--tests/armv8/a64.rs2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/armv8/a64.rs b/src/armv8/a64.rs
index 0704262..a1fc8bf 100644
--- a/src/armv8/a64.rs
+++ b/src/armv8/a64.rs
@@ -2872,7 +2872,7 @@ pub enum Operand {
///
/// this operand will display as, for example, `cr5`.
ControlReg(u16),
- /// a selector for a field of the `pstate` control register.
+ /// a selector for a field of the `pstate` control registers.
///
/// `yaxpeax-arm` does not name specific fields of `pstate` yet, so this operand displays as
/// `pstate.0x50`.
@@ -2937,7 +2937,7 @@ impl Display for Operand {
}
}
Operand::PstateField(reg) => {
- // `MSR (immediate)` writes to the `PSTATE` register, setting a few bit patterns as
+ // `MSR (immediate)` writes to the `PSTATE` registers, setting a few bit patterns as
// selected by `reg`.
write!(fmt, "pstate.{:#x}", reg)
}
@@ -10399,7 +10399,7 @@ impl Decoder<ARMv8> for InstDecoder {
*/
inst.operands = [
- Operand::PstateField(((op1 << 3) | op2 << 3) as u8),
+ Operand::PstateField(((op1 << 3) | op2) as u8),
Operand::Imm16(
((word >> 8) & 0xf) as u16
),
diff --git a/tests/armv8/a64.rs b/tests/armv8/a64.rs
index 577028e..b3838cc 100644
--- a/tests/armv8/a64.rs
+++ b/tests/armv8/a64.rs
@@ -4866,7 +4866,7 @@ fn test_misc() {
([0x00, 0x30, 0xc0, 0x9a], "pacga x0, x0, x0"),
([0x00, 0x00, 0xae, 0x9e], "fmov x0, v0.d[1]"),
([0x00, 0x00, 0xe6, 0x9e], "fmov x0, h0"),
- ([0x7f, 0x41, 0x00, 0xd5], "msr pstate.0x58, #0x1"),
+ ([0x7f, 0x41, 0x00, 0xd5], "msr pstate.0x3, #0x1"),
([0x00, 0x68, 0x20, 0x38], "strb w0, [x0, x0]"),
];
let errs = run_tests(TESTS);