aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2024-03-17 11:27:48 -0700
committeriximeow <me@iximeow.net>2024-03-17 11:27:48 -0700
commita29e738354b55c39d19b42838af2f091b2cc8973 (patch)
treea039cec152f07ca4f9494dd7243f87989af303f9 /src
parent9d60c5ed015f2739f2696e2c8150beb25421fc3f (diff)
at least armv7t doesnt panic now, but im very uncertain these are right
Diffstat (limited to 'src')
-rw-r--r--src/armv7/thumb.rs42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/armv7/thumb.rs b/src/armv7/thumb.rs
index 45151cd..5f6abec 100644
--- a/src/armv7/thumb.rs
+++ b/src/armv7/thumb.rs
@@ -1526,7 +1526,12 @@ pub fn decode_into<T: Reader<<ARMv7 as Arch>::Address, <ARMv7 as Arch>::Word>>(d
inst.opcode = Opcode::MSR;
inst.operands = [
// TODO: is this the appropriate banked reg?
- Reg::from_sysm(R, sysm as u8).expect("from_sysm works"),
+ if let Some(op) = Reg::from_sysm(R, sysm as u8) {
+ // TODO: from_sysm should succeed?
+ op
+ } else {
+ return Err(DecodeError::InvalidOperand);
+ },
Operand::Reg(Reg::from_u8(rn)),
Operand::Nothing,
Operand::Nothing,
@@ -1570,7 +1575,12 @@ pub fn decode_into<T: Reader<<ARMv7 as Arch>::Address, <ARMv7 as Arch>::Word>>(d
inst.opcode = Opcode::MSR;
inst.operands = [
// TODO: is this the appropriate?
- Reg::from_sysm(R, mask).expect("from_sysm works"),
+ if let Some(op) = Reg::from_sysm(R, mask) {
+ // TODO: from_sysm should succeed?
+ op
+ } else {
+ return Err(DecodeError::InvalidOperand);
+ },
Operand::Reg(Reg::from_u8(rn)),
Operand::Nothing,
Operand::Nothing,
@@ -1583,7 +1593,12 @@ pub fn decode_into<T: Reader<<ARMv7 as Arch>::Address, <ARMv7 as Arch>::Word>>(d
inst.opcode = Opcode::MSR;
inst.operands = [
// TODO: is this the appropriate?
- Reg::from_sysm(R, mask).expect("from_sysm works"),
+ if let Some(op) = Reg::from_sysm(R, mask) {
+ // TODO: from_sysm should succeed?
+ op
+ } else {
+ return Err(DecodeError::InvalidOperand);
+ },
Operand::Reg(Reg::from_u8(rn)),
Operand::Nothing,
Operand::Nothing,
@@ -1850,7 +1865,12 @@ pub fn decode_into<T: Reader<<ARMv7 as Arch>::Address, <ARMv7 as Arch>::Word>>(d
inst.opcode = Opcode::MRS;
inst.operands = [
Operand::Reg(Reg::from_u8(rd)),
- Reg::from_sysm(r != 0, sysm as u8).expect("from_sysm works"),
+ if let Some(op) = Reg::from_sysm(r != 0, sysm as u8) {
+ // TODO: from_sysm should succeed?
+ op
+ } else {
+ return Err(DecodeError::InvalidOperand);
+ },
Operand::Nothing,
Operand::Nothing,
];
@@ -1864,7 +1884,12 @@ pub fn decode_into<T: Reader<<ARMv7 as Arch>::Address, <ARMv7 as Arch>::Word>>(d
inst.operands = [
Operand::Reg(Reg::from_u8(rd)),
// TODO: "<spec_reg>"?
- Reg::from_sysm(false, 0).expect("from_sysm works"),
+ if let Some(op) = Reg::from_sysm(false, 0) {
+ // TODO: from_sysm should succeed?
+ op
+ } else {
+ return Err(DecodeError::InvalidOperand);
+ },
Operand::Nothing,
Operand::Nothing,
];
@@ -1878,7 +1903,12 @@ pub fn decode_into<T: Reader<<ARMv7 as Arch>::Address, <ARMv7 as Arch>::Word>>(d
inst.operands = [
Operand::Reg(Reg::from_u8(rd)),
// TODO: "<spec_reg>"?
- Reg::from_sysm(r != 0, 0).expect("from_sysm works"),
+ if let Some(op) = Reg::from_sysm(r != 0, 0) {
+ // TODO: from_sysm should succeed?
+ op
+ } else {
+ return Err(DecodeError::InvalidOperand);
+ },
Operand::Nothing,
Operand::Nothing,
];