#![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 IclassMovRA1Rrx;
impl IclassMovRA1Rrx {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let stype = (data >> 5) & 3;
let stype_post = stype;
let Rm = (data >> 0) & 15;
let Rm_post = Rm;
let S = (data >> 20) & 1;
let S_post = S;
let opc = (data >> 21) & 3;
let opc_post = opc;
let imm5 = (data >> 7) & 31;
let imm5_post = imm5;
let Rd = (data >> 12) & 15;
let Rd_post = Rd;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let field_4 = (data >> 4) & 1;
let field_4_post = field_4;
let field_27 = (data >> 23) & 31;
let field_27_post = field_27;
let cond = (data >> 28) & 15;
let cond_post = cond;
if ((S_post == 0) && ((imm5_post == 0) && (stype_post == 3))) {
return MovRA1Rrx::decode(data as u32, decoder);
}
if ((S_post == 0) && !((((imm5_post == 0) && (stype_post == 3))))) {
return MovRA1::decode(data as u32, decoder);
}
if ((S_post == 1) && ((imm5_post == 0) && (stype_post == 3))) {
return MovsRA1Rrx::decode(data as u32, decoder);
}
if ((S_post == 1) && !((((imm5_post == 0) && (stype_post == 3))))) {
return MovsRA1::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct MovRA1Rrx;
impl MovRA1Rrx {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::MOV
}
pub fn condition(_instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let cond = (data >> 28) & 15;
let cond_post = cond;
let S = (data >> 20) & 1;
let S_post = S;
let Rd = (data >> 12) & 15;
let Rd_post = Rd;
let imm5 = (data >> 7) & 31;
let imm5_post = imm5;
let stype = (data >> 5) & 3;
let stype_post = stype;
let Rm = (data >> 0) & 15;
let Rm_post = Rm;
match decoder.config.instructions.mov_r_a1_rrx.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((S_post == 0) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxMovRA1Rrx::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::RrxMovRA1Rrx::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((S_post == 0) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxMovRA1Rrx::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRA1RrxAliases::RrxMovRA1Rrx => {
if ((S_post == 0) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxMovRA1Rrx::decode(data, decoder);
}
}
};
if ((S_post == 0) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxMovRA1Rrx::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRA1RrxAliases::RrxMovRA1Rrx => return super::RrxMovRA1Rrx::decode(data, decoder),
}
},
}
}
let cond_post = cond;
let op_0 = MnemonicCondition::decode(cond_post)?;
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 = Shift::RRX;
let mut instr = Instruction::builder(Code::MOV_r_A1_RRX)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let cond_pre = instr.op0().as_mnemonic_condition()?.encode();
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let cond = (cond_pre & 15);
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let mut instr: u32 = 0b00000001101000000000000001100000;
instr |= (cond & 15) << 28;
instr |= (Rd & 15) << 12;
instr |= (Rm & 15) << 0;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Shift(Shift::RRX) = op {
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1_rrx, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRA1RrxAliases {
RrxMovRA1Rrx,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRA1RrxEncodings {
None
}
pub struct MovRA1;
impl MovRA1 {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::MOV
}
pub fn condition(_instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let cond = (data >> 28) & 15;
let cond_post = cond;
let S = (data >> 20) & 1;
let S_post = S;
let Rd = (data >> 12) & 15;
let Rd_post = Rd;
let imm5 = (data >> 7) & 31;
let imm5_post = imm5;
let stype = (data >> 5) & 3;
let stype_post = stype;
let Rm = (data >> 0) & 15;
let Rm_post = Rm;
match decoder.config.instructions.mov_r_a1.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((S_post == 0) && (stype_post == 2)) {
return super::AsrMovRA1::decode(data, decoder);
}
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslMovRA1::decode(data, decoder);
}
if ((S_post == 0) && (stype_post == 1)) {
return super::LsrMovRA1::decode(data, decoder);
}
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorMovRA1::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::AsrMovRA1::decode(data, decoder);
return super::LslMovRA1::decode(data, decoder);
return super::LsrMovRA1::decode(data, decoder);
return super::RorMovRA1::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((S_post == 0) && (stype_post == 2)) {
return super::AsrMovRA1::decode(data, decoder);
}
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslMovRA1::decode(data, decoder);
}
if ((S_post == 0) && (stype_post == 1)) {
return super::LsrMovRA1::decode(data, decoder);
}
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorMovRA1::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovRA1Aliases::AsrMovRA1 => {
if ((S_post == 0) && (stype_post == 2)) {
return super::AsrMovRA1::decode(data, decoder);
}
}
MovRA1Aliases::LslMovRA1 => {
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslMovRA1::decode(data, decoder);
}
}
MovRA1Aliases::LsrMovRA1 => {
if ((S_post == 0) && (stype_post == 1)) {
return super::LsrMovRA1::decode(data, decoder);
}
}
MovRA1Aliases::RorMovRA1 => {
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorMovRA1::decode(data, decoder);
}
}
};
if ((S_post == 0) && (stype_post == 2)) {
return super::AsrMovRA1::decode(data, decoder);
}
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslMovRA1::decode(data, decoder);
}
if ((S_post == 0) && (stype_post == 1)) {
return super::LsrMovRA1::decode(data, decoder);
}
if ((S_post == 0) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorMovRA1::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovRA1Aliases::AsrMovRA1 => return super::AsrMovRA1::decode(data, decoder),
MovRA1Aliases::LslMovRA1 => return super::LslMovRA1::decode(data, decoder),
MovRA1Aliases::LsrMovRA1 => return super::LsrMovRA1::decode(data, decoder),
MovRA1Aliases::RorMovRA1 => return super::RorMovRA1::decode(data, decoder),
}
},
}
}
let cond_post = cond;
let op_0 = MnemonicCondition::decode(cond_post)?;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let imm5_post = imm5;
let op_3 = match stype {
0 => if imm5_post == 0 {
Operand::None
} else {
Operand::Shift(Shift::LSL(imm5_post))
}
1 => if imm5_post == 0 {
Operand::Shift(Shift::LSR(32))
} else {
Operand::Shift(Shift::LSR(imm5_post))
}
2 => if imm5_post == 0 {
Operand::Shift(Shift::ASR(32))
} else {
Operand::Shift(Shift::ASR(imm5_post))
}
3 => if imm5_post == 0 {
Operand::Shift(Shift::RRX)
} else {
Operand::Shift(Shift::ROR(imm5_post))
}
_ => todo!(),
};
let mut instr = Instruction::builder(Code::MOV_r_A1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let cond_pre = instr.op0().as_mnemonic_condition()?.encode();
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let (stype_pre, imm5_pre) = {
if let Operand::None = instr.op3() {
(0, 0)
} else {
match instr.op3().as_shift()? {
Shift::LSL(value) => (0, *value),
Shift::LSR(value) => (1, *value),
Shift::ASR(value) => (2, *value),
Shift::ROR(value) => (3, *value),
Shift::RRX => (3, 0),
_ => todo!(),
}
}
};
let cond = (cond_pre & 15);
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let stype = (stype_pre & 3);
let imm5 = (imm5_pre & 31);
let mut instr: u32 = 0b00000001101000000000000000000000;
instr |= (cond & 15) << 28;
instr |= (Rd & 15) << 12;
instr |= (Rm & 15) << 0;
instr |= (stype & 3) << 5;
instr |= (imm5 & 31) << 7;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if op.is_none() {
return Ok(())
}
if let Operand::Shift(s) = op {
match s {
Shift::LSL(value) => if *value < 1 || *value > 31 {
todo!()
}
Shift::LSR(value) => if *value < 1 || *value > 32 {
todo!()
}
Shift::ASR(value) => if *value < 1 || *value > 32 {
todo!()
}
Shift::ROR(value) => if *value < 1 || *value > 31 {
todo!()
}
Shift::RRX => {}
_ => todo!(),
}
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.mov_r_a1, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.mov_r_a1, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_r_a1, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.mov_r_a1, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1, &instr, 2)?;
if !instr.op3().is_none() {
fmt.format_punctuation(output, &config.global, &config.instructions.mov_r_a1, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.mov_r_a1, &instr, 3)?;
};
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRA1Aliases {
AsrMovRA1,
LslMovRA1,
LsrMovRA1,
RorMovRA1,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovRA1Encodings {
None
}
pub struct MovsRA1Rrx;
impl MovsRA1Rrx {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::MOVS
}
pub fn condition(_instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let cond = (data >> 28) & 15;
let cond_post = cond;
let S = (data >> 20) & 1;
let S_post = S;
let Rd = (data >> 12) & 15;
let Rd_post = Rd;
let imm5 = (data >> 7) & 31;
let imm5_post = imm5;
let stype = (data >> 5) & 3;
let stype_post = stype;
let Rm = (data >> 0) & 15;
let Rm_post = Rm;
match decoder.config.instructions.movs_r_a1_rrx.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((S_post == 1) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxsMovsRA1Rrx::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::RrxsMovsRA1Rrx::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((S_post == 1) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxsMovsRA1Rrx::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovsRA1RrxAliases::RrxsMovsRA1Rrx => {
if ((S_post == 1) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxsMovsRA1Rrx::decode(data, decoder);
}
}
};
if ((S_post == 1) && ((imm5_post == 0) && (stype_post == 3))) {
return super::RrxsMovsRA1Rrx::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovsRA1RrxAliases::RrxsMovsRA1Rrx => return super::RrxsMovsRA1Rrx::decode(data, decoder),
}
},
}
}
let cond_post = cond;
let op_0 = MnemonicCondition::decode(cond_post)?;
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 = Shift::RRX;
let mut instr = Instruction::builder(Code::MOVS_r_A1_RRX)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let cond_pre = instr.op0().as_mnemonic_condition()?.encode();
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let cond = (cond_pre & 15);
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let mut instr: u32 = 0b00000001101100000000000001100000;
instr |= (cond & 15) << 28;
instr |= (Rd & 15) << 12;
instr |= (Rm & 15) << 0;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Shift(Shift::RRX) = op {
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1_rrx, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovsRA1RrxAliases {
RrxsMovsRA1Rrx,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovsRA1RrxEncodings {
None
}
pub struct MovsRA1;
impl MovsRA1 {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::MOVS
}
pub fn condition(_instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let cond = (data >> 28) & 15;
let cond_post = cond;
let S = (data >> 20) & 1;
let S_post = S;
let Rd = (data >> 12) & 15;
let Rd_post = Rd;
let imm5 = (data >> 7) & 31;
let imm5_post = imm5;
let stype = (data >> 5) & 3;
let stype_post = stype;
let Rm = (data >> 0) & 15;
let Rm_post = Rm;
match decoder.config.instructions.movs_r_a1.aliases {
None => match decoder.config.global.aliases {
FormatAliasGlobal::Never => {},
FormatAliasGlobal::Recommended => {
if ((S_post == 1) && (stype_post == 2)) {
return super::AsrsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && (stype_post == 1)) {
return super::LsrsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorsMovsRA1::decode(data, decoder);
}
},
FormatAliasGlobal::Always => {
return super::AsrsMovsRA1::decode(data, decoder);
return super::LslsMovsRA1::decode(data, decoder);
return super::LsrsMovsRA1::decode(data, decoder);
return super::RorsMovsRA1::decode(data, decoder);
}
}
Some(pref) => match pref {
FormatAliasInstruction::Never => {},
FormatAliasInstruction::Recommended => {
if ((S_post == 1) && (stype_post == 2)) {
return super::AsrsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && (stype_post == 1)) {
return super::LsrsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorsMovsRA1::decode(data, decoder);
}
},
FormatAliasInstruction::Preferred(alias) => {
match alias {
MovsRA1Aliases::AsrsMovsRA1 => {
if ((S_post == 1) && (stype_post == 2)) {
return super::AsrsMovsRA1::decode(data, decoder);
}
}
MovsRA1Aliases::LslsMovsRA1 => {
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslsMovsRA1::decode(data, decoder);
}
}
MovsRA1Aliases::LsrsMovsRA1 => {
if ((S_post == 1) && (stype_post == 1)) {
return super::LsrsMovsRA1::decode(data, decoder);
}
}
MovsRA1Aliases::RorsMovsRA1 => {
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorsMovsRA1::decode(data, decoder);
}
}
};
if ((S_post == 1) && (stype_post == 2)) {
return super::AsrsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 0))) {
return super::LslsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && (stype_post == 1)) {
return super::LsrsMovsRA1::decode(data, decoder);
}
if ((S_post == 1) && ((imm5_post != 0) && (stype_post == 3))) {
return super::RorsMovsRA1::decode(data, decoder);
}
},
FormatAliasInstruction::Always(alias) => {
match alias {
MovsRA1Aliases::AsrsMovsRA1 => return super::AsrsMovsRA1::decode(data, decoder),
MovsRA1Aliases::LslsMovsRA1 => return super::LslsMovsRA1::decode(data, decoder),
MovsRA1Aliases::LsrsMovsRA1 => return super::LsrsMovsRA1::decode(data, decoder),
MovsRA1Aliases::RorsMovsRA1 => return super::RorsMovsRA1::decode(data, decoder),
}
},
}
}
let cond_post = cond;
let op_0 = MnemonicCondition::decode(cond_post)?;
let Rd_post = Rd;
let op_1 = Register::decode(Rd_post)?;
let Rm_post = Rm;
let op_2 = Register::decode(Rm_post)?;
let imm5_post = imm5;
let op_3 = match stype {
0 => if imm5_post == 0 {
Operand::None
} else {
Operand::Shift(Shift::LSL(imm5_post))
}
1 => if imm5_post == 0 {
Operand::Shift(Shift::LSR(32))
} else {
Operand::Shift(Shift::LSR(imm5_post))
}
2 => if imm5_post == 0 {
Operand::Shift(Shift::ASR(32))
} else {
Operand::Shift(Shift::ASR(imm5_post))
}
3 => if imm5_post == 0 {
Operand::Shift(Shift::RRX)
} else {
Operand::Shift(Shift::ROR(imm5_post))
}
_ => todo!(),
};
let mut instr = Instruction::builder(Code::MOVS_r_A1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let cond_pre = instr.op0().as_mnemonic_condition()?.encode();
let Rd_pre = instr.op1().as_register()?.encode();
let Rm_pre = instr.op2().as_register()?.encode();
let (stype_pre, imm5_pre) = {
if let Operand::None = instr.op3() {
(0, 0)
} else {
match instr.op3().as_shift()? {
Shift::LSL(value) => (0, *value),
Shift::LSR(value) => (1, *value),
Shift::ASR(value) => (2, *value),
Shift::ROR(value) => (3, *value),
Shift::RRX => (3, 0),
_ => todo!(),
}
}
};
let cond = (cond_pre & 15);
let Rd = (Rd_pre & 15);
let Rm = (Rm_pre & 15);
let stype = (stype_pre & 3);
let imm5 = (imm5_pre & 31);
let mut instr: u32 = 0b00000001101100000000000000000000;
instr |= (cond & 15) << 28;
instr |= (Rd & 15) << 12;
instr |= (Rm & 15) << 0;
instr |= (stype & 3) << 5;
instr |= (imm5 & 31) << 7;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
pub fn encode_block(instr: &mut Instruction, buf: &mut Vec<u8>, labels: &std::collections::HashMap<u64, u64>) -> Result<usize> {
Self::encode(instr, buf)
}
pub fn check_op0(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::MnemonicCondition(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if op.is_none() {
return Ok(())
}
if let Operand::Shift(s) = op {
match s {
Shift::LSL(value) => if *value < 1 || *value > 31 {
todo!()
}
Shift::LSR(value) => if *value < 1 || *value > 32 {
todo!()
}
Shift::ASR(value) => if *value < 1 || *value > 32 {
todo!()
}
Shift::ROR(value) => if *value < 1 || *value > 31 {
todo!()
}
Shift::RRX => {}
_ => todo!(),
}
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op5(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn check_op6(instr: &Instruction, op: &Operand) -> Result<()> {
todo!()
}
pub fn format(instr: &Instruction, fmt: &mut impl Formatter, output: &mut impl FormatterOutput, config: &Config) -> Result<()> {
fmt.format_mnemonic(output, &config.global, &config.instructions.movs_r_a1, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.movs_r_a1, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_r_a1, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.movs_r_a1, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1, &instr, 2)?;
if !instr.op3().is_none() {
fmt.format_punctuation(output, &config.global, &config.instructions.movs_r_a1, &instr, FormatterTextKind::Comma)?;
fmt.format_operand(output, &config.global, &config.instructions.movs_r_a1, &instr, 3)?;
};
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovsRA1Aliases {
AsrsMovsRA1,
LslsMovsRA1,
LsrsMovsRA1,
RorsMovsRA1,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum MovsRA1Encodings {
None
}