From 0a9479ddaa4d83957e06f56d3990d2b7d666baaa Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 6 Dec 2020 02:47:15 -0800 Subject: fix regimm masks --- src/armv7.rs | 3 +-- src/armv7/thumb.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/armv7.rs b/src/armv7.rs index aa7aa03..c7fb6e4 100644 --- a/src/armv7.rs +++ b/src/armv7.rs @@ -860,8 +860,7 @@ pub struct RegShift { impl RegShift { fn into_shift(&self) -> RegShiftStyle { - // TODO: is this mask really off by one. should it be 0b10000?? - if self.data & 0b1000 == 0 { + if self.data & 0b10000 == 0 { RegShiftStyle::RegImm(RegImmShift { data: self.data }) } else { RegShiftStyle::RegReg(RegRegShift { data: self.data }) diff --git a/src/armv7/thumb.rs b/src/armv7/thumb.rs index c78842d..ab42bd8 100644 --- a/src/armv7/thumb.rs +++ b/src/armv7/thumb.rs @@ -90,7 +90,7 @@ fn DecodeImmShift(reg: u8, ty: u8, imm5: u8) -> RegShift { } }; RegShift::from_raw( - 0b1000 | // `RegImm` + 0b00000 | // `RegImm` reg as u16 | ((ty as u16) << 5)| ((imm as u16) << 7) @@ -365,7 +365,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I // want `, LSL #1`, construct a raw shift // ourselves RegShift::from_raw( - 0b1000 | // `RegImm` + 0b10000 | // `RegImm` rd as u16 | // reg == rd (0b00 << 5) | // LSL (1 << 7) // shift == #1 @@ -709,7 +709,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I let rm = lower2[0..4].load::(); let shift = RegShift::from_raw( - 0b1000 | // reg-imm shift. TODO: probably need to change the const + 0b00000 | // reg-imm shift. TODO: probably need to change the const rm as u16 | (imm2 << 7) | (imm3 << 9) | tp << 5 @@ -1921,7 +1921,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I Reg::from_u8(rn), RegShift::from_raw( // do things - 0b0000 | // imm shift + 0b00000 | // imm shift (imm2 << 7) | // imm rm as u16 | // shiftee (0b00 << 5) // shift style (lsl) @@ -2008,7 +2008,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I Reg::from_u8(rn), RegShift::from_raw( // do things - 0b0000 | // imm shift + 0b00000 | // imm shift (imm2 << 7) | // imm rm as u16 | // shiftee (0b00 << 5) // shift style (lsl) @@ -2094,7 +2094,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I Reg::from_u8(rn), RegShift::from_raw( // do things - 0b0000 | // imm shift + 0b00000 | // imm shift (imm2 << 7) | // imm rm as u16 | // shiftee (0b00 << 5) // shift style (lsl) @@ -2337,7 +2337,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I Operand::RegDerefPreindexRegShift( Reg::from_u8(rn), RegShift::from_raw( - 0b1000 | // `RegImm` + 0b00000 | // `RegImm` rm as u16 | ((0 /* lsl */) << 5)| ((imm2 as u16) << 7) @@ -2580,7 +2580,7 @@ pub fn decode_into>(decoder: &InstDecoder, inst: &mut I Operand::RegDerefPreindexRegShift( Reg::from_u8(rn), RegShift::from_raw( - 0b1000 | // `RegImm` + 0b00000 | // `RegImm` rm as u16 | ((0 /* lsl */) << 5)| ((imm2 as u16) << 7) -- cgit v1.1