aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-12-06 02:47:15 -0800
committeriximeow <me@iximeow.net>2020-12-06 11:58:57 -0800
commit0a9479ddaa4d83957e06f56d3990d2b7d666baaa (patch)
tree48b85a629da3c13f25cf6844628f5f0c85c52bb0
parentc2874f05ab0f92bbcc4c5129dbec14157af32c56 (diff)
fix regimm masks
-rw-r--r--src/armv7.rs3
-rw-r--r--src/armv7/thumb.rs16
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<T: IntoIterator<Item=u8>>(decoder: &InstDecoder, inst: &mut I
// want `<Rm>, 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<T: IntoIterator<Item=u8>>(decoder: &InstDecoder, inst: &mut I
let rm = lower2[0..4].load::<u16>();
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<T: IntoIterator<Item=u8>>(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<T: IntoIterator<Item=u8>>(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<T: IntoIterator<Item=u8>>(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<T: IntoIterator<Item=u8>>(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<T: IntoIterator<Item=u8>>(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)