#![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 IclassLdrbIT1;
impl IclassLdrbIT1 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let field_15 = (data >> 13) & 7;
let field_15_post = field_15;
let Rn = (data >> 3) & 7;
let Rn_post = Rn;
let imm5 = (data >> 6) & 31;
let imm5_post = imm5;
let L = (data >> 11) & 1;
let L_post = L;
let Rt = (data >> 0) & 7;
let Rt_post = Rt;
let B = (data >> 12) & 1;
let B_post = B;
return LdrbIT1::decode(data as u32, decoder);
unreachable!()
}
}
pub struct LdrbIT1;
impl LdrbIT1 {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRB
}
pub fn condition(instr: &Instruction) -> ConditionalInstruction {
ConditionalInstruction::Condition(0, false, false)
}
pub fn size(_instr: &Instruction) -> usize {2}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm5 = (data >> 6) & 31;
let imm5_post = imm5;
let Rn = (data >> 3) & 7;
let Rn_post = Rn;
let Rt = (data >> 0) & 7;
let Rt_post = Rt;
let imm5_post = imm5;
let Rt_post = Rt;
let Rn_post = Rn;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::decode(Rt_post)?;
let op_2 = Register::decode(Rn_post)?;
let op_3 = imm5_post as u32;
let mut instr = Instruction::builder(Code::LDRB_i_T1)
.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 Rt_pre = instr.op1().as_register()?.encode();
let Rn_pre = instr.op2().as_register()?.encode();
let imm5_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 7);
let Rn = (Rn_pre & 7);
let imm5_pre = imm5_pre;
let imm5 = (imm5_pre & 31);
let mut instr: u32 = 0b0111100000000000;
instr |= (Rt & 7) << 0;
instr |= (Rn & 7) << 3;
instr |= (imm5 & 31) << 6;
let instr = instr as u16;
buf.extend(instr.to_le_bytes());
Ok(2)
}
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::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.ldrb_i_t1, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t1, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterQualifier::Narrow, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t1, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t1, &instr, 2)?;
if instr.op3().as_unsigned_immediate()? != 0 {
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::NumSign)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::Plus)?;
;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t1, &instr, 3)?;
};
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t1, &instr, FormatterTextKind::BracketRight)?;;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT1Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT1Encodings {
None
}
pub(crate) struct IclassLdrbIT2;
impl IclassLdrbIT2 {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rt = (data >> 12) & 15;
let Rt_post = Rt;
let imm12 = (data >> 0) & 4095;
let imm12_post = imm12;
let size = (data >> 21) & 3;
let size_post = size;
let field_28 = (data >> 25) & 15;
let field_28_post = field_28;
let field_31 = (data >> 29) & 7;
let field_31_post = field_31;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let L = (data >> 20) & 1;
let L_post = L;
let field_24 = (data >> 23) & 3;
let field_24_post = field_24;
return LdrbIT2::decode(data as u32, decoder);
unreachable!()
}
}
pub struct LdrbIT2;
impl LdrbIT2 {
pub fn mnemonic(instr: &Instruction) -> Mnemonic {
match instr.encoding {
Encoding::Alt1 => Mnemonic::LDRB,
Encoding::Alt2 => Mnemonic::LDRB,
_ => 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 Rn = (data >> 16) & 15;
let Rn_post = Rn;
let Rt = (data >> 12) & 15;
let Rt_post = Rt;
let imm12 = (data >> 0) & 4095;
let imm12_post = imm12;
let Rt_post = Rt;
let Rn_post = Rn;
let imm12_post = imm12;
if let Some(encoding) = decoder.config.instructions.ldrb_i_t2.encodings {
match encoding {
LdrbIT2Encodings::Alt2 => {
let op_0 = MnemonicCondition::Al;
let Rt_post = Rt;
let op_1 = Register::decode(Rt_post)?;
let Rn_post = Rn;
let op_2 = Register::decode(Rn_post)?;
let imm12_post = imm12;
let op_3 = imm12_post as u32;
let mut instr = Instruction::builder_multi(Code::LDRB_i_T2, Encoding::Alt2)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
LdrbIT2Encodings::Alt1 => {
let op_0 = MnemonicCondition::Al;
let Rt_post = Rt;
let op_1 = Register::decode(Rt_post)?;
let Rn_post = Rn;
let op_2 = Register::decode(Rn_post)?;
let imm12_post = imm12;
let op_3 = imm12_post as u32;
let mut instr = Instruction::builder_multi(Code::LDRB_i_T2, Encoding::Alt1)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.build();
return Ok(instr);
}
}
}
if ((Rt_post <= 7 && Rn_post <= 7 && imm12_post <= 31)) {
let op_0 = MnemonicCondition::Al;
let Rt_post = Rt;
let op_1 = Register::decode(Rt_post)?;
let Rn_post = Rn;
let op_2 = Register::decode(Rn_post)?;
let imm12_post = imm12;
let op_3 = imm12_post as u32;
let mut instr = Instruction::builder_multi(Code::LDRB_i_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 Rt_post = Rt;
let op_1 = Register::decode(Rt_post)?;
let Rn_post = Rn;
let op_2 = Register::decode(Rn_post)?;
let imm12_post = imm12;
let op_3 = imm12_post as u32;
let mut instr = Instruction::builder_multi(Code::LDRB_i_T2, Encoding::Alt1)
.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::Alt2 => {
let Rt_pre = instr.op1().as_register()?.encode();
let Rn_pre = instr.op2().as_register()?.encode();
let imm12_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 15);
let Rn = (Rn_pre & 15);
let imm12_pre = imm12_pre;
let imm12 = (imm12_pre & 4095);
let mut instr: u32 = 0b11111000100100000000000000000000;
instr |= (Rt & 15) << 12;
instr |= (Rn & 15) << 16;
instr |= (imm12 & 4095) << 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 Rt_pre = instr.op1().as_register()?.encode();
let Rn_pre = instr.op2().as_register()?.encode();
let imm12_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 15);
let Rn = (Rn_pre & 15);
let imm12_pre = imm12_pre;
let imm12 = (imm12_pre & 4095);
let mut instr: u32 = 0b11111000100100000000000000000000;
instr |= (Rt & 15) << 12;
instr |= (Rn & 15) << 16;
instr |= (imm12 & 4095) << 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::SignedImmediate(i) = op {
if *i < 0 || *i > 4095 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=4095).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
Encoding::Alt1 => {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 4095 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=4095).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
_ => todo!()
}
unreachable!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
match instr.encoding {
Encoding::Alt2 => {
todo!()
}
Encoding::Alt1 => {
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.ldrb_i_t2, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterQualifier::Wide, true, true)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 2)?;
if instr.op3().as_unsigned_immediate()? != 0 {
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::NumSign)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Plus)?;
;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 3)?;
};
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::BracketRight)?;;
return Ok(());
}
Encoding::Alt1 => {
fmt.format_mnemonic(output, &config.global, &config.instructions.ldrb_i_t2, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 2)?;
if instr.op3().as_unsigned_immediate()? != 0 {
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::NumSign)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::Plus)?;
;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t2, &instr, 3)?;
};
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t2, &instr, FormatterTextKind::BracketRight)?;;
return Ok(());
}
_ => todo!()
}
unreachable!()
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT2Aliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT2Encodings {
Alt2,
Alt1,
}
pub(crate) struct IclassLdrbIT3Off;
impl IclassLdrbIT3Off {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let Rt = (data >> 12) & 15;
let Rt_post = Rt;
let size = (data >> 21) & 3;
let size_post = size;
let field_11 = (data >> 11) & 1;
let field_11_post = field_11;
let U = (data >> 9) & 1;
let U_post = U;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let Rn = (data >> 16) & 15;
let Rn_post = Rn;
let field_31 = (data >> 23) & 511;
let field_31_post = field_31;
let L = (data >> 20) & 1;
let L_post = L;
let W = (data >> 8) & 1;
let W_post = W;
let P = (data >> 10) & 1;
let P_post = P;
if ((Rt_post != 15) && ((P_post == 1) && ((U_post == 0) && (W_post == 0)))) {
return LdrbIT3Off::decode(data as u32, decoder);
}
if ((P_post == 0) && (W_post == 1)) {
return LdrbIT3Post::decode(data as u32, decoder);
}
if ((P_post == 1) && (W_post == 1)) {
return LdrbIT3Pre::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct LdrbIT3Off;
impl LdrbIT3Off {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRB
}
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 Rn = (data >> 16) & 15;
let Rn_post = Rn;
let Rt = (data >> 12) & 15;
let Rt_post = Rt;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let Rt_post = Rt;
let imm8_post = imm8;
let Rn_post = Rn;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::decode(Rt_post)?;
let op_2 = Register::decode(Rn_post)?;
let op_3 = imm8_post as u32;
let mut instr = Instruction::builder(Code::LDRB_i_T3_off)
.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 Rt_pre = instr.op1().as_register()?.encode();
let Rn_pre = instr.op2().as_register()?.encode();
let imm8_pre = instr.op3().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 15);
let Rn = (Rn_pre & 15);
let imm8_pre = imm8_pre;
let imm8 = (imm8_pre & 255);
let mut instr: u32 = 0b11111000000100000000110000000000;
instr |= (Rt & 15) << 12;
instr |= (Rn & 15) << 16;
instr |= (imm8 & 255) << 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(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::SignedImmediate(i) = op {
if *i < 0 || *i > 255 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=255).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.ldrb_i_t3_off, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, 2)?;
if true || instr.op3().as_unsigned_immediate()? != 0 {
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::NumSign)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::Minus)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, 3)?;
};
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_off, &instr, FormatterTextKind::BracketRight)?;;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT3OffAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT3OffEncodings {
None
}
pub struct LdrbIT3Post;
impl LdrbIT3Post {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRB
}
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 Rn = (data >> 16) & 15;
let Rn_post = Rn;
let Rt = (data >> 12) & 15;
let Rt_post = Rt;
let U = (data >> 9) & 1;
let U_post = U;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let imm8_post = imm8;
let Rt_post = Rt;
let U_post = U;
let Rn_post = Rn;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::decode(Rt_post)?;
let op_2 = Register::decode(Rn_post)?;
let op_3 = PlusMinus::decode(U_post);
let op_4 = imm8_post as u32;
let mut instr = Instruction::builder(Code::LDRB_i_T3_post)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op1().as_register()?.encode();
let Rn_pre = instr.op2().as_register()?.encode();
let U_pre = instr.op3().as_plus_minus()?.encode();
let imm8_pre = instr.op4().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 15);
let Rn = (Rn_pre & 15);
let U = (U_pre & 1);
let imm8_pre = imm8_pre;
let imm8 = (imm8_pre & 255);
let mut instr: u32 = 0b11111000000100000000100100000000;
instr |= (Rt & 15) << 12;
instr |= (Rn & 15) << 16;
instr |= (U & 1) << 9;
instr |= (imm8 & 255) << 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(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::PlusMinus(_) = op {
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 255 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=255).contains(i) {
todo!()
}
return Ok(())
}
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.ldrb_i_t3_post, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterTextKind::BracketRight)?;;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, FormatterTextKind::NumSign)?;
if *instr.op3().as_plus_minus()? == PlusMinus::Minus {
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, 3)?;
};
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_post, &instr, 4)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT3PostAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT3PostEncodings {
None
}
pub struct LdrbIT3Pre;
impl LdrbIT3Pre {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRB
}
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 Rn = (data >> 16) & 15;
let Rn_post = Rn;
let Rt = (data >> 12) & 15;
let Rt_post = Rt;
let U = (data >> 9) & 1;
let U_post = U;
let imm8 = (data >> 0) & 255;
let imm8_post = imm8;
let imm8_post = imm8;
let Rt_post = Rt;
let U_post = U;
let Rn_post = Rn;
let op_0 = MnemonicCondition::Al;
let op_1 = Register::decode(Rt_post)?;
let op_2 = Register::decode(Rn_post)?;
let op_3 = PlusMinus::decode(U_post);
let op_4 = imm8_post as u32;
let mut instr = Instruction::builder(Code::LDRB_i_T3_pre)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.operand(3, op_3)?
.operand(4, op_4)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op1().as_register()?.encode();
let Rn_pre = instr.op2().as_register()?.encode();
let U_pre = instr.op3().as_plus_minus()?.encode();
let imm8_pre = instr.op4().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 15);
let Rn = (Rn_pre & 15);
let U = (U_pre & 1);
let imm8_pre = imm8_pre;
let imm8 = (imm8_pre & 255);
let mut instr: u32 = 0b11111000000100000000110100000000;
instr |= (Rt & 15) << 12;
instr |= (Rn & 15) << 16;
instr |= (U & 1) << 9;
instr |= (imm8 & 255) << 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(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::PlusMinus(_) = op {
return Ok(())
}
todo!()
}
pub fn check_op4(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if *i < 0 || *i > 255 {
todo!()
}
return Ok(())
}
if let Operand::UnsignedImmediate(i) = op {
if !(0..=255).contains(i) {
todo!()
}
return Ok(())
}
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.ldrb_i_t3_pre, &instr)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, 0)?;
fmt.format_qualifier(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterQualifier::Wide, true, false)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::NumSign)?;
if *instr.op3().as_plus_minus()? == PlusMinus::Minus {
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, 3)?;
};
fmt.format_operand(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, 4)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::BracketRight)?;;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrb_i_t3_pre, &instr, FormatterTextKind::ExclamationMark)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT3PreAliases {
None,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum LdrbIT3PreEncodings {
None
}