From 2b0930355d87d7f195a7ff05d18b09b61a5ea490 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 16 Mar 2024 23:35:23 +0000 Subject: ldrab and ldraa tests, fix immediate decoding --- src/armv8/a64.rs | 10 ++++++---- tests/armv8/a64.rs | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/armv8/a64.rs b/src/armv8/a64.rs index cdee6d5..de7a743 100644 --- a/src/armv8/a64.rs +++ b/src/armv8/a64.rs @@ -9105,8 +9105,10 @@ impl Decoder for InstDecoder { // V==0 let w = (word >> 11) & 1; let imm9 = ((word >> 12) & 0b1_1111_1111) as i16; - let imm9 = ((imm9 << 7) >> 7) as i32; - let imm9 = imm9 << 3; // `simm` is stored as a multiple of 8 + let S = ((word >> 22) & 1) as i16; + let imm10 = imm9 | (S << 9); + let imm10 = imm10 << 3; // `simm` is stored as a multiple of 8 + let imm10 = ((imm10 << 3) >> 3) as i32; let m = (word >> 23) & 1; let size = (word >> 30) & 0b11; if size != 0b11 { @@ -9122,9 +9124,9 @@ impl Decoder for InstDecoder { inst.operands = [ Operand::Register(SizeCode::X, Rt), if w == 0 { - Operand::RegPreIndex(Rn, imm9, false) + Operand::RegPreIndex(Rn, imm10, false) } else { - Operand::RegPreIndex(Rn, imm9, true) + Operand::RegPreIndex(Rn, imm10, true) }, Operand::Nothing, Operand::Nothing, diff --git a/tests/armv8/a64.rs b/tests/armv8/a64.rs index 7f6fd04..1d04a76 100644 --- a/tests/armv8/a64.rs +++ b/tests/armv8/a64.rs @@ -4756,6 +4756,11 @@ fn test_vec_shift() { fn test_pac() { const TESTS: &[([u8; 4], &'static str)] = &[ ([0x00, 0x04, 0xc1, 0xda], "pacib x0, x0"), + ([0x00, 0x04, 0xa8, 0xf8], "ldrab x0, [x0, #0x400]"), + ([0x00, 0x04, 0xb0, 0xf8], "ldrab x0, [x0, #0x800]"), + ([0x00, 0x04, 0xf0, 0xf8], "ldrab x0, [x0, #-0x800]"), + ([0x00, 0x14, 0x20, 0xf8], "ldraa x0, [x0, #0x8]"), + ([0x00, 0x04, 0xa4, 0xf8], "ldrab x0, [x0, #0x200]"), ]; let errs = run_tests(TESTS); -- cgit v1.1