From a29e738354b55c39d19b42838af2f091b2cc8973 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 17 Mar 2024 11:27:48 -0700 Subject: at least armv7t doesnt panic now, but im very uncertain these are right --- src/armv7/thumb.rs | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'src/armv7') 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::Address, ::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::Address, ::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::Address, ::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::Address, ::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::Address, ::Word>>(d inst.operands = [ Operand::Reg(Reg::from_u8(rd)), // TODO: ""? - 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::Address, ::Word>>(d inst.operands = [ Operand::Reg(Reg::from_u8(rd)), // TODO: ""? - 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, ]; -- cgit v1.1