#![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 IclassRfedaA1As;
impl IclassRfedaA1As {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let U = (data >> 23) & 1;
let U_post = U;
let field_31 = (data >> 25) & 127;
let field_31_post = field_31;
let S = (data >> 22) & 1;
let S_post = S;
let P = (data >> 24) & 1;
let P_post = P;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let mode = (data >> 0) & 31;
let mode_post = mode;
let L = (data >> 20) & 1;
let L_post = L;
let W = (data >> 21) & 1;
let W_post = W;
let op = (data >> 5) & 2047;
let op_post = op;
if ((P_post == 0) && (U_post == 0)) {
return RfedaA1As::decode(data as u32, decoder);
}
if ((P_post == 1) && (U_post == 0)) {
return RfedbA1As::decode(data as u32, decoder);
}
if ((P_post == 0) && (U_post == 1)) {
return RfeiaA1As::decode(data as u32, decoder);
}
if ((P_post == 1) && (U_post == 1)) {
return RfeibA1As::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct RfedaA1As;
impl RfedaA1As {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::RFEDA,
Encoding::Alt2 => Mnemonic::RFEFA,
_ => 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::Alt1 => 4,
Encoding::Alt2 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let W = (data >> 21) & 1;
let W_post = W;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let W_post = W;
let Rn_post = Rn;
if let Some(encoding) = decoder.config.instructions.rfeda_a1_as.encodings {
match encoding {
RfedaA1AsEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDA_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
RfedaA1AsEncodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDA_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
}
}
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDA_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDA_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111000000100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
Encoding::Alt2 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111000000100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
_ => todo!()
}
}
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<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
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 {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
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.rfeda_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeda_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfeda_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfeda_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeda_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeda_a1_as, &instr, 2)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.rfeda_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeda_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfeda_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfeda_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeda_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeda_a1_as, &instr, 2)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfedaA1AsAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfedaA1AsEncodings {
Alt1,
Alt2,
}
pub struct RfedbA1As;
impl RfedbA1As {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::RFEDB,
Encoding::Alt2 => Mnemonic::RFEEA,
_ => 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::Alt1 => 4,
Encoding::Alt2 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let W = (data >> 21) & 1;
let W_post = W;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let W_post = W;
let Rn_post = Rn;
if let Some(encoding) = decoder.config.instructions.rfedb_a1_as.encodings {
match encoding {
RfedbA1AsEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDB_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
RfedbA1AsEncodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDB_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
}
}
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDB_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEDB_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111001000100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
Encoding::Alt2 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111001000100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
_ => todo!()
}
}
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<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
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 {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
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.rfedb_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfedb_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfedb_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfedb_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfedb_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfedb_a1_as, &instr, 2)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.rfedb_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfedb_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfedb_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfedb_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfedb_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfedb_a1_as, &instr, 2)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfedbA1AsAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfedbA1AsEncodings {
Alt1,
Alt2,
}
pub struct RfeiaA1As;
impl RfeiaA1As {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::RFE,
Encoding::Alt2 => Mnemonic::RFEFD,
_ => 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::Alt1 => 4,
Encoding::Alt2 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let W = (data >> 21) & 1;
let W_post = W;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let W_post = W;
let Rn_post = Rn;
if let Some(encoding) = decoder.config.instructions.rfeia_a1_as.encodings {
match encoding {
RfeiaA1AsEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIA_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
RfeiaA1AsEncodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIA_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
}
}
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIA_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIA_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111000100100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
Encoding::Alt2 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111000100100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
_ => todo!()
}
}
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<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
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 {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
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.rfeia_a1_as, &instr)?;
if !config.instructions.rfeia_a1_as.syntax.get_omit_address_mode(&config.global.syntax) {
fmt.format_text(output, &config.global, &config.instructions.rfeia_a1_as, &instr, "ia")?;
};
fmt.format_operand(output, &config.global, &config.instructions.rfeia_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfeia_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfeia_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeia_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeia_a1_as, &instr, 2)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.rfeia_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeia_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfeia_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfeia_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeia_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeia_a1_as, &instr, 2)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfeiaA1AsAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfeiaA1AsEncodings {
Alt1,
Alt2,
}
pub struct RfeibA1As;
impl RfeibA1As {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::RFEIB,
Encoding::Alt2 => Mnemonic::RFEED,
_ => 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::Alt1 => 4,
Encoding::Alt2 => 4,
_ => todo!()
}
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let W = (data >> 21) & 1;
let W_post = W;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let W_post = W;
let Rn_post = Rn;
if let Some(encoding) = decoder.config.instructions.rfeib_a1_as.encodings {
match encoding {
RfeibA1AsEncodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIB_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
RfeibA1AsEncodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIB_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
}
}
}
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIB_A1_AS, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
let op_0 = MnemonicCondition::Al;
let Rn_post = Rn;
let op_1 = Register::decode(Rn_post)?;
let W_post = W;
let op_2 = WriteBack::decode(W_post);
let instr = Instruction::builder_multi(Code::RFEIB_A1_AS, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
return Ok(instr);
unreachable!()
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
match instr.encoding {
Encoding::Alt1 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111001100100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
Encoding::Alt2 => {
let Rn_pre = instr.op1().as_register()?.encode();
let W_pre = instr.op2().as_write_back()?.encode();
let Rn = (Rn_pre & 15);
let W = (W_pre & 1);
let mut instr: u32 = 0b11111001100100000000101000000000;
instr |= (Rn & 15) << 16;
instr |= (W & 1) << 21;
let bytes = instr.to_le_bytes();
let len = bytes.len();
buf.extend(bytes);
Ok(len)
}
_ => todo!()
}
}
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<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::MnemonicCondition(MnemonicCondition::Al) = op {
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 {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::Register(r) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
Encoding::Alt2 => {
if let Operand::WriteBack(_) = op {
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
todo!()
}
Encoding::Alt2 => {
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt1 => {
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.rfeib_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeib_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfeib_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfeib_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeib_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeib_a1_as, &instr, 2)?;
return Ok(());
}
Encoding::Alt2 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.rfeib_a1_as, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeib_a1_as, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.rfeib_a1_as, &instr, FormatterQualifier::Wide, false, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.rfeib_a1_as, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeib_a1_as, &instr, 1)?;
fmt.format_operand(output, &config.global, &config.instructions.rfeib_a1_as, &instr, 2)?;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfeibA1AsAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum RfeibA1AsEncodings {
Alt1,
Alt2,
}