#![allow(non_snake_case)]
#![allow(unused)]
use crate::error::Result;
use crate::utils::*;
use super::super::formatter::*;
use super::super::instruction::*;
use super::super::operand::*;
use super::super::consts::*;
use super::super::config::*;
use super::super::decoder::*;
pub(crate) struct IclassMovRrT1Asr;
impl IclassMovRrT1Asr {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rs = (data >> 3) & 7;
let Rs_post = Rs;
let op = (data >> 6) & 15;
let op_post = op;
let field_15 = (data >> 10) & 63;
let field_15_post = field_15;
let Rdm = (data >> 0) & 7;
let Rdm_post = Rdm;
if (op_post == 4) {
return MovRrT1Asr::decode(data as u32, decoder);
}
if (op_post == 2) {
return MovRrT1Lsl::decode(data as u32, decoder);
}
if (op_post == 3) {
return MovRrT1Lsr::decode(data as u32, decoder);
}
if (op_post == 7) {
return MovRrT1Ror::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct MovRrT1Asr;
impl MovRrT1Asr {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::MOV,
Encoding::Alt2 => Mnemonic::MOVS,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::None
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt1 => 2 ,
Encoding::Alt2 => 2 ,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let op = (data >> 6) & 15;
let op_post = op;
let Rs = (data >> 3) & 7;
let Rs_post = Rs;
let Rdm = (data >> 0) & 7;
let Rdm_post = Rdm;
let Rs_post = Rs;
let Rdm_post = Rdm;
match decoder.config.instructions.mov_rr_t1_asr.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((op_post == 4) && !(decoder.it_block.is_some())) {
return super::AsrsMovRrT1Asr::decode(data, decoder);
}
if ((op_post == 4) && decoder.it_block.is_some()) {
return super::AsrMovRrT1Asr::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::AsrsMovRrT1Asr::decode(data, decoder);
return super::AsrMovRrT1Asr::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((op_post == 4) && !(decoder.it_block.is_some())) {
return super::AsrsMovRrT1Asr::decode(data, decoder);
}
if ((op_post == 4) && decoder.it_block.is_some()) {
return super::AsrMovRrT1Asr::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRrT1AsrAliases::AsrsMovRrT1Asr => {
if ((op_post == 4) && !(decoder.it_block.is_some())) {
return super::AsrsMovRrT1Asr::decode(data, decoder);
}
}
MovRrT1AsrAliases::AsrMovRrT1Asr => {
if ((op_post == 4) && decoder.it_block.is_some()) {
return super::AsrMovRrT1Asr::decode(data, decoder);
}
}
};
if ((op_post == 4) && !(decoder.it_block.is_some())) {
return super::AsrsMovRrT1Asr::decode(data, decoder);
}
if ((op_post == 4) && decoder.it_block.is_some()) {
return super::AsrMovRrT1Asr::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRrT1AsrAliases::AsrsMovRrT1Asr => return super::AsrsMovRrT1Asr::decode(data, decoder),
MovRrT1AsrAliases::AsrMovRrT1Asr => return super::AsrMovRrT1Asr::decode(data, decoder),
}
},
}
}
if let Some(encoding) = decoder.config.instructions.mov_rr_t1_asr.encodings {
match encoding {
MovRrT1AsrEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::ASR;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ASR, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
MovRrT1AsrEncodings::Alt2 => {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::ASR;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ASR, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if (!decoder.it_block.is_none()) {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::ASR;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ASR, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
if (decoder.it_block.is_none()) {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::ASR;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ASR, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rdm_pre = instr.op1().as_register()?.encode();
let Rdm_pre = instr.op2().as_register()?.encode();
let Rs_pre = instr.op4().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000100000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
Encoding::Alt2 => {
let Rdm_pre = instr.op0().as_register()?.encode();
let Rdm_pre = instr.op1().as_register()?.encode();
let Rs_pre = instr.op3().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000100000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
Self::encode(instr, buf)
}
Encoding::Alt2 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op2().is_none() && instr.op2().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op0().is_none() && instr.op0().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::ShiftType(ShiftType::ASR) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::ShiftType(ShiftType::ASR) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 4)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 2)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_asr, &instr, 3)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1AsrAliases {
AsrsMovRrT1Asr,AsrMovRrT1Asr,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1AsrEncodings {
Alt1,
Alt2,
}
pub struct MovRrT1Lsl;
impl MovRrT1Lsl {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::MOV,
Encoding::Alt2 => Mnemonic::MOVS,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::None
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt1 => 2 ,
Encoding::Alt2 => 2 ,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let op = (data >> 6) & 15;
let op_post = op;
let Rs = (data >> 3) & 7;
let Rs_post = Rs;
let Rdm = (data >> 0) & 7;
let Rdm_post = Rdm;
let Rs_post = Rs;
let Rdm_post = Rdm;
match decoder.config.instructions.mov_rr_t1_lsl.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((op_post == 2) && !(decoder.it_block.is_some())) {
return super::LslsMovRrT1Lsl::decode(data, decoder);
}
if ((op_post == 2) && decoder.it_block.is_some()) {
return super::LslMovRrT1Lsl::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::LslsMovRrT1Lsl::decode(data, decoder);
return super::LslMovRrT1Lsl::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((op_post == 2) && !(decoder.it_block.is_some())) {
return super::LslsMovRrT1Lsl::decode(data, decoder);
}
if ((op_post == 2) && decoder.it_block.is_some()) {
return super::LslMovRrT1Lsl::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRrT1LslAliases::LslsMovRrT1Lsl => {
if ((op_post == 2) && !(decoder.it_block.is_some())) {
return super::LslsMovRrT1Lsl::decode(data, decoder);
}
}
MovRrT1LslAliases::LslMovRrT1Lsl => {
if ((op_post == 2) && decoder.it_block.is_some()) {
return super::LslMovRrT1Lsl::decode(data, decoder);
}
}
};
if ((op_post == 2) && !(decoder.it_block.is_some())) {
return super::LslsMovRrT1Lsl::decode(data, decoder);
}
if ((op_post == 2) && decoder.it_block.is_some()) {
return super::LslMovRrT1Lsl::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRrT1LslAliases::LslsMovRrT1Lsl => return super::LslsMovRrT1Lsl::decode(data, decoder),
MovRrT1LslAliases::LslMovRrT1Lsl => return super::LslMovRrT1Lsl::decode(data, decoder),
}
},
}
}
if let Some(encoding) = decoder.config.instructions.mov_rr_t1_lsl.encodings {
match encoding {
MovRrT1LslEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::LSL;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSL, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
MovRrT1LslEncodings::Alt2 => {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::LSL;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSL, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if (!decoder.it_block.is_none()) {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::LSL;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSL, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
if (decoder.it_block.is_none()) {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::LSL;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSL, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rdm_pre = instr.op1().as_register()?.encode();
let Rdm_pre = instr.op2().as_register()?.encode();
let Rs_pre = instr.op4().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000010000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
Encoding::Alt2 => {
let Rdm_pre = instr.op0().as_register()?.encode();
let Rdm_pre = instr.op1().as_register()?.encode();
let Rs_pre = instr.op3().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000010000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
Self::encode(instr, buf)
}
Encoding::Alt2 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op2().is_none() && instr.op2().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op0().is_none() && instr.op0().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::ShiftType(ShiftType::LSL) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::ShiftType(ShiftType::LSL) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 4)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 2)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsl, &instr, 3)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1LslAliases {
LslsMovRrT1Lsl,LslMovRrT1Lsl,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1LslEncodings {
Alt1,
Alt2,
}
pub struct MovRrT1Lsr;
impl MovRrT1Lsr {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::MOV,
Encoding::Alt2 => Mnemonic::MOVS,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::None
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt1 => 2 ,
Encoding::Alt2 => 2 ,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let op = (data >> 6) & 15;
let op_post = op;
let Rs = (data >> 3) & 7;
let Rs_post = Rs;
let Rdm = (data >> 0) & 7;
let Rdm_post = Rdm;
let Rs_post = Rs;
let Rdm_post = Rdm;
match decoder.config.instructions.mov_rr_t1_lsr.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((op_post == 3) && !(decoder.it_block.is_some())) {
return super::LsrsMovRrT1Lsr::decode(data, decoder);
}
if ((op_post == 3) && decoder.it_block.is_some()) {
return super::LsrMovRrT1Lsr::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::LsrsMovRrT1Lsr::decode(data, decoder);
return super::LsrMovRrT1Lsr::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((op_post == 3) && !(decoder.it_block.is_some())) {
return super::LsrsMovRrT1Lsr::decode(data, decoder);
}
if ((op_post == 3) && decoder.it_block.is_some()) {
return super::LsrMovRrT1Lsr::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRrT1LsrAliases::LsrsMovRrT1Lsr => {
if ((op_post == 3) && !(decoder.it_block.is_some())) {
return super::LsrsMovRrT1Lsr::decode(data, decoder);
}
}
MovRrT1LsrAliases::LsrMovRrT1Lsr => {
if ((op_post == 3) && decoder.it_block.is_some()) {
return super::LsrMovRrT1Lsr::decode(data, decoder);
}
}
};
if ((op_post == 3) && !(decoder.it_block.is_some())) {
return super::LsrsMovRrT1Lsr::decode(data, decoder);
}
if ((op_post == 3) && decoder.it_block.is_some()) {
return super::LsrMovRrT1Lsr::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRrT1LsrAliases::LsrsMovRrT1Lsr => return super::LsrsMovRrT1Lsr::decode(data, decoder),
MovRrT1LsrAliases::LsrMovRrT1Lsr => return super::LsrMovRrT1Lsr::decode(data, decoder),
}
},
}
}
if let Some(encoding) = decoder.config.instructions.mov_rr_t1_lsr.encodings {
match encoding {
MovRrT1LsrEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::LSR;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSR, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
MovRrT1LsrEncodings::Alt2 => {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::LSR;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSR, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if (!decoder.it_block.is_none()) {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::LSR;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSR, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
if (decoder.it_block.is_none()) {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::LSR;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_LSR, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rdm_pre = instr.op1().as_register()?.encode();
let Rdm_pre = instr.op2().as_register()?.encode();
let Rs_pre = instr.op4().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000011000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
Encoding::Alt2 => {
let Rdm_pre = instr.op0().as_register()?.encode();
let Rdm_pre = instr.op1().as_register()?.encode();
let Rs_pre = instr.op3().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000011000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
Self::encode(instr, buf)
}
Encoding::Alt2 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op2().is_none() && instr.op2().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op0().is_none() && instr.op0().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::ShiftType(ShiftType::LSR) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::ShiftType(ShiftType::LSR) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 4)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 2)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_lsr, &instr, 3)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1LsrAliases {
LsrsMovRrT1Lsr,LsrMovRrT1Lsr,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1LsrEncodings {
Alt1,
Alt2,
}
pub struct MovRrT1Ror;
impl MovRrT1Ror {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::MOV,
Encoding::Alt2 => Mnemonic::MOVS,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::None
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt1 => 2 ,
Encoding::Alt2 => 2 ,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let op = (data >> 6) & 15;
let op_post = op;
let Rs = (data >> 3) & 7;
let Rs_post = Rs;
let Rdm = (data >> 0) & 7;
let Rdm_post = Rdm;
let Rs_post = Rs;
let Rdm_post = Rdm;
match decoder.config.instructions.mov_rr_t1_ror.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((op_post == 7) && !(decoder.it_block.is_some())) {
return super::RorsMovRrT1Ror::decode(data, decoder);
}
if ((op_post == 7) && decoder.it_block.is_some()) {
return super::RorMovRrT1Ror::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::RorsMovRrT1Ror::decode(data, decoder);
return super::RorMovRrT1Ror::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((op_post == 7) && !(decoder.it_block.is_some())) {
return super::RorsMovRrT1Ror::decode(data, decoder);
}
if ((op_post == 7) && decoder.it_block.is_some()) {
return super::RorMovRrT1Ror::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRrT1RorAliases::RorsMovRrT1Ror => {
if ((op_post == 7) && !(decoder.it_block.is_some())) {
return super::RorsMovRrT1Ror::decode(data, decoder);
}
}
MovRrT1RorAliases::RorMovRrT1Ror => {
if ((op_post == 7) && decoder.it_block.is_some()) {
return super::RorMovRrT1Ror::decode(data, decoder);
}
}
};
if ((op_post == 7) && !(decoder.it_block.is_some())) {
return super::RorsMovRrT1Ror::decode(data, decoder);
}
if ((op_post == 7) && decoder.it_block.is_some()) {
return super::RorMovRrT1Ror::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRrT1RorAliases::RorsMovRrT1Ror => return super::RorsMovRrT1Ror::decode(data, decoder),
MovRrT1RorAliases::RorMovRrT1Ror => return super::RorMovRrT1Ror::decode(data, decoder),
}
},
}
}
if let Some(encoding) = decoder.config.instructions.mov_rr_t1_ror.encodings {
match encoding {
MovRrT1RorEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::ROR;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ROR, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
MovRrT1RorEncodings::Alt2 => {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::ROR;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ROR, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if (!decoder.it_block.is_none()) {
let op_0 = MnemonicCondition::Al;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_2 = Register::decode(Rdm_post)?;
let op_3 = ShiftType::ROR;
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ROR, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
if (decoder.it_block.is_none()) {
let Rdm_post = Rdm;
let op_0 = Register::decode(Rdm_post)?;
let Rdm_post = Rdm;
let op_1 = Register::decode(Rdm_post)?;
let op_2 = ShiftType::ROR;
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T1_ROR, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rdm_pre = instr.op1().as_register()?.encode();
let Rdm_pre = instr.op2().as_register()?.encode();
let Rs_pre = instr.op4().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000111000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
Encoding::Alt2 => {
let Rdm_pre = instr.op0().as_register()?.encode();
let Rdm_pre = instr.op1().as_register()?.encode();
let Rs_pre = instr.op3().as_register()?.encode();
let Rdm = (Rdm_pre & 7);
let Rdm = (Rdm_pre & 7);
let Rs = (Rs_pre & 7);
let mut instr: u32 = 0b0100000111000000;
instr |= (Rdm & 7) << 0;
instr |= (Rdm & 7) << 0;
instr |= (Rs & 7) << 3;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
return Ok(2);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
Self::encode(instr, buf)
}
Encoding::Alt2 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op2().is_none() && instr.op2().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
if !instr.op0().is_none() && instr.op0().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
if !instr.op1().is_none() && instr.op1().as_register()? != r {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::ShiftType(ShiftType::ROR) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::ShiftType(ShiftType::ROR) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 4)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 2)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t1_ror, &instr, 3)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1RorAliases {
RorsMovRrT1Ror,RorMovRrT1Ror,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT1RorEncodings {
Alt1,
Alt2,
}
pub(crate) struct IclassMovsRrT2;
impl IclassMovsRrT2 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rm = (data >> 16) & 15;
let Rm_post = Rm;
let field_15 = (data >> 12) & 15;
let field_15_post = field_15;
let field_7 = (data >> 4) & 15;
let field_7_post = field_7;
let S = (data >> 20) & 1;
let S_post = S;
let Rs = (data >> 0) & 15;
let Rs_post = Rs;
let stype = (data >> 21) & 3;
let stype_post = stype;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let field_31 = (data >> 23) & 511;
let field_31_post = field_31;
if (S_post == 1) {
return MovsRrT2::decode(data as u32, decoder);
}
if (S_post == 0) {
return MovRrT2::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct MovsRrT2;
impl MovsRrT2 {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::MOVS,
Encoding::Alt2 => Mnemonic::MOVS,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::None
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt2 => 4,
Encoding::Alt1 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let stype = (data >> 21) & 3;
let stype_post = stype;
let S = (data >> 20) & 1;
let S_post = S;
let Rm = (data >> 16) & 15;
let Rm_post = Rm;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let Rs = (data >> 0) & 15;
let Rs_post = Rs;
let Rs_post = Rs;
let Rd_post = Rd;
let Rm_post = Rm;
match decoder.config.instructions.movs_rr_t2.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((stype_post == 2) && (S_post == 1)) {
return super::AsrsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 0) && (S_post == 1)) {
return super::LslsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 1) && (S_post == 1)) {
return super::LsrsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 3) && (S_post == 1)) {
return super::RorsMovsRrT2::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::AsrsMovsRrT2::decode(data, decoder);
return super::LslsMovsRrT2::decode(data, decoder);
return super::LsrsMovsRrT2::decode(data, decoder);
return super::RorsMovsRrT2::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((stype_post == 2) && (S_post == 1)) {
return super::AsrsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 0) && (S_post == 1)) {
return super::LslsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 1) && (S_post == 1)) {
return super::LsrsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 3) && (S_post == 1)) {
return super::RorsMovsRrT2::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovsRrT2Aliases::AsrsMovsRrT2 => {
if ((stype_post == 2) && (S_post == 1)) {
return super::AsrsMovsRrT2::decode(data, decoder);
}
}
MovsRrT2Aliases::LslsMovsRrT2 => {
if ((stype_post == 0) && (S_post == 1)) {
return super::LslsMovsRrT2::decode(data, decoder);
}
}
MovsRrT2Aliases::LsrsMovsRrT2 => {
if ((stype_post == 1) && (S_post == 1)) {
return super::LsrsMovsRrT2::decode(data, decoder);
}
}
MovsRrT2Aliases::RorsMovsRrT2 => {
if ((stype_post == 3) && (S_post == 1)) {
return super::RorsMovsRrT2::decode(data, decoder);
}
}
};
if ((stype_post == 2) && (S_post == 1)) {
return super::AsrsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 0) && (S_post == 1)) {
return super::LslsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 1) && (S_post == 1)) {
return super::LsrsMovsRrT2::decode(data, decoder);
}
if ((stype_post == 3) && (S_post == 1)) {
return super::RorsMovsRrT2::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovsRrT2Aliases::AsrsMovsRrT2 => return super::AsrsMovsRrT2::decode(data, decoder),
MovsRrT2Aliases::LslsMovsRrT2 => return super::LslsMovsRrT2::decode(data, decoder),
MovsRrT2Aliases::LsrsMovsRrT2 => return super::LsrsMovsRrT2::decode(data, decoder),
MovsRrT2Aliases::RorsMovsRrT2 => return super::RorsMovsRrT2::decode(data, decoder),
}
},
}
}
if let Some(encoding) = decoder.config.instructions.movs_rr_t2.encodings {
match encoding {
MovsRrT2Encodings::Alt2 => {
let Rd_post = Rd;
let op_0 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_1 = Register::decode(Rm_post)?;
let op_2 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOVS_rr_T2, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
MovsRrT2Encodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let op_3 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOVS_rr_T2, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
}
}
if (decoder.it_block.is_none()) && ((Rd_post <= 7 && Rm_post <= 7 && Rs_post <= 7)) {
let Rd_post = Rd;
let op_0 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_1 = Register::decode(Rm_post)?;
let op_2 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_3 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOVS_rr_T2, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let op_3 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOVS_rr_T2, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt2 => {
let Rd_pre = instr.op0().as_register()?.encode();
let Rm_pre = instr.op1().as_register()?.encode();
let stype = match instr.op2().as_shift_type()? {
ShiftType::LSL => 0,
ShiftType::LSR => 1,
ShiftType::ASR => 2,
ShiftType::ROR => 3,
_ => todo!(),
};
let Rs_pre = instr.op3().as_register()?.encode();
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let Rs = (Rs_pre & 15);
let mut instr: u32 = 0b11111010000100001111000000000000;
instr |= (Rd & 15) << 8;
instr |= (Rm & 15) << 16;
instr |= (stype & 3) << 21;
instr |= (Rs & 15) << 0;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
Encoding::Alt1 => {
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let stype = match instr.op3().as_shift_type()? {
ShiftType::LSL => 0,
ShiftType::LSR => 1,
ShiftType::ASR => 2,
ShiftType::ROR => 3,
_ => todo!(),
};
let Rs_pre = instr.op4().as_register()?.encode();
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let Rs = (Rs_pre & 15);
let mut instr: u32 = 0b11111010000100001111000000000000;
instr |= (Rd & 15) << 8;
instr |= (Rm & 15) << 16;
instr |= (stype & 3) << 21;
instr |= (Rs & 15) << 0;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt2 => {
Self::encode(instr, buf)
}
Encoding::Alt1 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::ShiftType(s) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::ShiftType(s) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.movs_rr_t2, &instr)?;
fmt.format_qualifier(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterQualifier::Wide, true, true)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 2)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 3)?;
return Ok(());
}
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.movs_rr_t2, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_rr_t2, &instr, 4)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovsRrT2Aliases {
AsrsMovsRrT2,LslsMovsRrT2,LsrsMovsRrT2,RorsMovsRrT2,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovsRrT2Encodings {
Alt2,
Alt1,
}
pub struct MovRrT2;
impl MovRrT2 {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::MOV,
Encoding::Alt2 => Mnemonic::MOV,
_ => todo!()
}
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
match instr.encoding {
Encoding::Alt1 => {
ConditionalInstruction::Condition(0, false, false)
}
Encoding::Alt2 => {
ConditionalInstruction::Condition(0, false, false)
}
_ => todo!()
}
}
pub fn size(instr: &Instruction) -> usize {
match instr.encoding {
Encoding::Alt2 => 4,
Encoding::Alt1 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let stype = (data >> 21) & 3;
let stype_post = stype;
let S = (data >> 20) & 1;
let S_post = S;
let Rm = (data >> 16) & 15;
let Rm_post = Rm;
let Rd = (data >> 8) & 15;
let Rd_post = Rd;
let Rs = (data >> 0) & 15;
let Rs_post = Rs;
let Rs_post = Rs;
let Rd_post = Rd;
let Rm_post = Rm;
match decoder.config.instructions.mov_rr_t2.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((stype_post == 2) && (S_post == 0)) {
return super::AsrMovRrT2::decode(data, decoder);
}
if ((stype_post == 0) && (S_post == 0)) {
return super::LslMovRrT2::decode(data, decoder);
}
if ((stype_post == 1) && (S_post == 0)) {
return super::LsrMovRrT2::decode(data, decoder);
}
if ((stype_post == 3) && (S_post == 0)) {
return super::RorMovRrT2::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::AsrMovRrT2::decode(data, decoder);
return super::LslMovRrT2::decode(data, decoder);
return super::LsrMovRrT2::decode(data, decoder);
return super::RorMovRrT2::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((stype_post == 2) && (S_post == 0)) {
return super::AsrMovRrT2::decode(data, decoder);
}
if ((stype_post == 0) && (S_post == 0)) {
return super::LslMovRrT2::decode(data, decoder);
}
if ((stype_post == 1) && (S_post == 0)) {
return super::LsrMovRrT2::decode(data, decoder);
}
if ((stype_post == 3) && (S_post == 0)) {
return super::RorMovRrT2::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRrT2Aliases::AsrMovRrT2 => {
if ((stype_post == 2) && (S_post == 0)) {
return super::AsrMovRrT2::decode(data, decoder);
}
}
MovRrT2Aliases::LslMovRrT2 => {
if ((stype_post == 0) && (S_post == 0)) {
return super::LslMovRrT2::decode(data, decoder);
}
}
MovRrT2Aliases::LsrMovRrT2 => {
if ((stype_post == 1) && (S_post == 0)) {
return super::LsrMovRrT2::decode(data, decoder);
}
}
MovRrT2Aliases::RorMovRrT2 => {
if ((stype_post == 3) && (S_post == 0)) {
return super::RorMovRrT2::decode(data, decoder);
}
}
};
if ((stype_post == 2) && (S_post == 0)) {
return super::AsrMovRrT2::decode(data, decoder);
}
if ((stype_post == 0) && (S_post == 0)) {
return super::LslMovRrT2::decode(data, decoder);
}
if ((stype_post == 1) && (S_post == 0)) {
return super::LsrMovRrT2::decode(data, decoder);
}
if ((stype_post == 3) && (S_post == 0)) {
return super::RorMovRrT2::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRrT2Aliases::AsrMovRrT2 => return super::AsrMovRrT2::decode(data, decoder),
MovRrT2Aliases::LslMovRrT2 => return super::LslMovRrT2::decode(data, decoder),
MovRrT2Aliases::LsrMovRrT2 => return super::LsrMovRrT2::decode(data, decoder),
MovRrT2Aliases::RorMovRrT2 => return super::RorMovRrT2::decode(data, decoder),
}
},
}
}
if let Some(encoding) = decoder.config.instructions.mov_rr_t2.encodings {
match encoding {
MovRrT2Encodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let op_3 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T2, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
MovRrT2Encodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let op_3 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T2, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
}
}
if (!decoder.it_block.is_none()) && ((Rd_post <= 7 && Rm_post <= 7 && Rs_post <= 7)) {
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let op_3 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T2, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
}
let op_0 = MnemonicCondition::Al;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let op_3 = match stype {
0 => ShiftType::LSL,
1 => ShiftType::LSR,
2 => ShiftType::ASR,
3 => ShiftType::ROR,
_ => todo!(),
};
let Rs_post = Rs;
let op_4 = Register::decode(Rs_post)?;
let mut instr = Instruction::builder_multi(Code::MOV_rr_T2, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt2 => {
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let stype = match instr.op3().as_shift_type()? {
ShiftType::LSL => 0,
ShiftType::LSR => 1,
ShiftType::ASR => 2,
ShiftType::ROR => 3,
_ => todo!(),
};
let Rs_pre = instr.op4().as_register()?.encode();
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let Rs = (Rs_pre & 15);
let mut instr: u32 = 0b11111010000000001111000000000000;
instr |= (Rd & 15) << 8;
instr |= (Rm & 15) << 16;
instr |= (stype & 3) << 21;
instr |= (Rs & 15) << 0;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
Encoding::Alt1 => {
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let stype = match instr.op3().as_shift_type()? {
ShiftType::LSL => 0,
ShiftType::LSR => 1,
ShiftType::ASR => 2,
ShiftType::ROR => 3,
_ => todo!(),
};
let Rs_pre = instr.op4().as_register()?.encode();
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let Rs = (Rs_pre & 15);
let mut instr: u32 = 0b11111010000000001111000000000000;
instr |= (Rd & 15) << 8;
instr |= (Rm & 15) << 16;
instr |= (stype & 3) << 21;
instr |= (Rs & 15) << 0;
let instr_1 = (instr & 0xffff) as u16;
let instr_2 = ((instr >> 16) & 0xffff) as u16;
buf.extend(instr_2.to_le_bytes());
buf.extend(instr_1.to_le_bytes());
return Ok(4);
}
_ => todo!()
}
unreachable!()
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
match instr.encoding {
Encoding::Alt2 => {
Self::encode(instr, buf)
}
Encoding::Alt1 => {
Self::encode(instr, buf)
}
_ => todo!()
}
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::ShiftType(s) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::ShiftType(s) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t2, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterQualifier::Wide, true, true)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 4)?;
return Ok(());
}
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_rr_t2, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_rr_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 3)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_rr_t2, &instr, 4)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT2Aliases {
AsrMovRrT2,LslMovRrT2,LsrMovRrT2,RorMovRrT2,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRrT2Encodings {
Alt2,
Alt1,
}