#![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 IclassSrsT1As;
impl IclassSrsT1As {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let field_22 = (data >> 22) & 1;
let field_22_post = field_22;
let field_28 = (data >> 25) & 15;
let field_28_post = field_28;
let opc = (data >> 23) & 3;
let opc_post = opc;
let field_31 = (data >> 29) & 7;
let field_31_post = field_31;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let field_13 = (data >> 5) & 511;
let field_13_post = field_13;
let L = (data >> 20) & 1;
let L_post = L;
let P = (data >> 15) & 1;
let P_post = P;
let mode = (data >> 0) & 31;
let mode_post = mode;
let W = (data >> 21) & 1;
let W_post = W;
let M = (data >> 14) & 1;
let M_post = M;
return SrsT1As::decode(data as u32, decoder);
unreachable!()
}
}
pub struct SrsT1As;
impl SrsT1As {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::SRSDB
}
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 W = (data >> 21) & 1;
let W_post = W;
let mode = (data >> 0) & 31;
let mode_post = mode;
let mode_post = mode;
let W_post = W;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::SP;
let op_2 = WriteBack::decode(W_post);
let op_3 = mode_post as u32;
let mut instr = Instruction::builder(Code::SRS_T1_AS)
.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 W_pre = instr.op2().as_write_back()?.encode();
let mode_pre = instr.op3().as_unsigned_immediate()? as u32;
let W = (W_pre & 1);
let mode_pre = mode_pre;
let mode = (mode_pre & 31);
let mut instr: u32 = 0b11101000000011011100000000000000;
instr |= (W & 1) << 21;
instr |= (mode & 31) << 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());
Ok(4)
}
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(Register::SP) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 31 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=31).contains(i) {
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.srs_t1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.srs_t1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.srs_t1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t1_as, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.srs_t1_as, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.srs_t1_as, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t1_as, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum SrsT1AsAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum SrsT1AsEncodings {
None
}
pub(crate) struct IclassSrsT2As;
impl IclassSrsT2As {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let field_22 = (data >> 22) & 1;
let field_22_post = field_22;
let field_28 = (data >> 25) & 15;
let field_28_post = field_28;
let opc = (data >> 23) & 3;
let opc_post = opc;
let field_31 = (data >> 29) & 7;
let field_31_post = field_31;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let field_13 = (data >> 5) & 511;
let field_13_post = field_13;
let L = (data >> 20) & 1;
let L_post = L;
let P = (data >> 15) & 1;
let P_post = P;
let mode = (data >> 0) & 31;
let mode_post = mode;
let W = (data >> 21) & 1;
let W_post = W;
let M = (data >> 14) & 1;
let M_post = M;
return SrsT2As::decode(data as u32, decoder);
unreachable!()
}
}
pub struct SrsT2As;
impl SrsT2As {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::SRS
}
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 W = (data >> 21) & 1;
let W_post = W;
let mode = (data >> 0) & 31;
let mode_post = mode;
let mode_post = mode;
let W_post = W;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::SP;
let op_2 = WriteBack::decode(W_post);
let op_3 = mode_post as u32;
let mut instr = Instruction::builder(Code::SRS_T2_AS)
.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 W_pre = instr.op2().as_write_back()?.encode();
let mode_pre = instr.op3().as_unsigned_immediate()? as u32;
let W = (W_pre & 1);
let mode_pre = mode_pre;
let mode = (mode_pre & 31);
let mut instr: u32 = 0b11101001100011011100000000000000;
instr |= (W & 1) << 21;
instr |= (mode & 31) << 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());
Ok(4)
}
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(Register::SP) = op {
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 31 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=31).contains(i) {
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.srs_t2_as, &instr)?;
if !config.instructions.srs_t2_as.syntax.get_omit_address_mode(&config.global.syntax) {
fmt.format_text(output, &config.global, &config.instructions.srs_t2_as, &instr, "ia")?;
};
fmt.format_operand(output, &config.global, &config.instructions.srs_t2_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.srs_t2_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.srs_t2_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t2_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t2_as, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.srs_t2_as, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.srs_t2_as, &instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.srs_t2_as, &instr, 3)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum SrsT2AsAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum SrsT2AsEncodings {
None
}