#![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 IclassLdrsb32LdstImmpost;
impl IclassLdrsb32LdstImmpost {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let size = (data >> 30) & 3;
let size_post = size;
let field_11 = (data >> 10) & 3;
let field_11_post = field_11;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let VR = (data >> 26) & 1;
let VR_post = VR;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let field_21 = (data >> 21) & 1;
let field_21_post = field_21;
let imm9 = (data >> 12) & 511;
let imm9_post = imm9;
let field_25 = (data >> 24) & 3;
let field_25_post = field_25;
let opc = (data >> 22) & 3;
let opc_post = opc;
let field_29 = (data >> 27) & 7;
let field_29_post = field_29;
if (opc_post == 3) {
return Ldrsb32LdstImmpost::decode(data as u32, decoder);
}
if (opc_post == 2) {
return Ldrsb64LdstImmpost::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct Ldrsb32LdstImmpost;
impl Ldrsb32LdstImmpost {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRSB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm9 = (data >> 12) & 511;
let imm9_post = imm9;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rn_post = Rn;
let op_1 = Register::aarch64(Rn_post, true)?;
let imm9_post = (((imm9) as i32) << 23) >> 23;
let op_2 = imm9_post as i32;
let mut instr = Instruction::builder(Code::LDRSB_32_ldst_immpost)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rn_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_signed_immediate()? as u32;
let Rt = (Rt_pre & 31);
let Rn = (Rn_pre & 31);
let imm9_pre = (imm9_pre) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b00111000110000000000010000000000;
instr |= (Rt & 31) << 0;
instr |= (Rn & 31) << 5;
instr |= (imm9 & 511) << 12;
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::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if !(-256..=255).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.ldrsb_32_ldst_immpost, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, FormatterTextKind::BracketRight)?;;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_immpost, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Ldrsb32LdstImmpostAliases {
None,
}
pub struct Ldrsb64LdstImmpost;
impl Ldrsb64LdstImmpost {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRSB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm9 = (data >> 12) & 511;
let imm9_post = imm9;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rn_post = Rn;
let op_1 = Register::aarch64(Rn_post, true)?;
let imm9_post = (((imm9) as i32) << 23) >> 23;
let op_2 = imm9_post as i32;
let mut instr = Instruction::builder(Code::LDRSB_64_ldst_immpost)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rn_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_signed_immediate()? as u32;
let Rt = (Rt_pre & 31);
let Rn = (Rn_pre & 31);
let imm9_pre = (imm9_pre) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b00111000100000000000010000000000;
instr |= (Rt & 31) << 0;
instr |= (Rn & 31) << 5;
instr |= (imm9 & 511) << 12;
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::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if !(-256..=255).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.ldrsb_64_ldst_immpost, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, FormatterTextKind::BracketRight)?;;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_immpost, instr, 2)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Ldrsb64LdstImmpostAliases {
None,
}
pub(crate) struct IclassLdrsb32LdstImmpre;
impl IclassLdrsb32LdstImmpre {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let size = (data >> 30) & 3;
let size_post = size;
let field_11 = (data >> 10) & 3;
let field_11_post = field_11;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let VR = (data >> 26) & 1;
let VR_post = VR;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let field_21 = (data >> 21) & 1;
let field_21_post = field_21;
let imm9 = (data >> 12) & 511;
let imm9_post = imm9;
let field_25 = (data >> 24) & 3;
let field_25_post = field_25;
let opc = (data >> 22) & 3;
let opc_post = opc;
let field_29 = (data >> 27) & 7;
let field_29_post = field_29;
if (opc_post == 3) {
return Ldrsb32LdstImmpre::decode(data as u32, decoder);
}
if (opc_post == 2) {
return Ldrsb64LdstImmpre::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct Ldrsb32LdstImmpre;
impl Ldrsb32LdstImmpre {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRSB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm9 = (data >> 12) & 511;
let imm9_post = imm9;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rn_post = Rn;
let op_1 = Register::aarch64(Rn_post, true)?;
let imm9_post = (((imm9) as i32) << 23) >> 23;
let op_2 = imm9_post as i32;
let mut instr = Instruction::builder(Code::LDRSB_32_ldst_immpre)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rn_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_signed_immediate()? as u32;
let Rt = (Rt_pre & 31);
let Rn = (Rn_pre & 31);
let imm9_pre = (imm9_pre) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b00111000110000000000110000000000;
instr |= (Rt & 31) << 0;
instr |= (Rn & 31) << 5;
instr |= (imm9 & 511) << 12;
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::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if !(-256..=255).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.ldrsb_32_ldst_immpre, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::BracketRight)?;;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_immpre, instr, FormatterTextKind::ExclamationMark)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Ldrsb32LdstImmpreAliases {
None,
}
pub struct Ldrsb64LdstImmpre;
impl Ldrsb64LdstImmpre {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRSB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm9 = (data >> 12) & 511;
let imm9_post = imm9;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rn_post = Rn;
let op_1 = Register::aarch64(Rn_post, true)?;
let imm9_post = (((imm9) as i32) << 23) >> 23;
let op_2 = imm9_post as i32;
let mut instr = Instruction::builder(Code::LDRSB_64_ldst_immpre)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rn_pre = instr.op1().as_register()?.encode();
let imm9_pre = instr.op2().as_signed_immediate()? as u32;
let Rt = (Rt_pre & 31);
let Rn = (Rn_pre & 31);
let imm9_pre = (imm9_pre) as u32;
let imm9 = (imm9_pre & 511);
let mut instr: u32 = 0b00111000100000000000110000000000;
instr |= (Rt & 31) << 0;
instr |= (Rn & 31) << 5;
instr |= (imm9 & 511) << 12;
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::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::SignedImmediate(i) = op {
if !(-256..=255).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.ldrsb_64_ldst_immpre, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, 1)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, 2)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::BracketRight)?;;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_immpre, instr, FormatterTextKind::ExclamationMark)?;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Ldrsb64LdstImmpreAliases {
None,
}
pub(crate) struct IclassLdrsb32LdstPos;
impl IclassLdrsb32LdstPos {
pub(crate) fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let size = (data >> 30) & 3;
let size_post = size;
let imm12 = (data >> 10) & 4095;
let imm12_post = imm12;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let VR = (data >> 26) & 1;
let VR_post = VR;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let field_25 = (data >> 24) & 3;
let field_25_post = field_25;
let opc = (data >> 22) & 3;
let opc_post = opc;
let field_29 = (data >> 27) & 7;
let field_29_post = field_29;
if (opc_post == 3) {
return Ldrsb32LdstPos::decode(data as u32, decoder);
}
if (opc_post == 2) {
return Ldrsb64LdstPos::decode(data as u32, decoder);
}
unreachable!()
}
}
pub struct Ldrsb32LdstPos;
impl Ldrsb32LdstPos {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRSB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm12 = (data >> 10) & 4095;
let imm12_post = imm12;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch32(Rt_post, false)?;
let Rn_post = Rn;
let op_1 = Register::aarch64(Rn_post, true)?;
let imm12_post = imm12;
let op_2 = imm12_post as u32;
let mut instr = Instruction::builder(Code::LDRSB_32_ldst_pos)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rn_pre = instr.op1().as_register()?.encode();
let imm12_pre = instr.op2().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 31);
let Rn = (Rn_pre & 31);
let imm12_pre = imm12_pre;
let imm12 = (imm12_pre & 4095);
let mut instr: u32 = 0b00111001110000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rn & 31) << 5;
instr |= (imm12 & 4095) << 10;
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::Register(r) = op {
if !r.is_aarch32() {
todo!()
}
if *r == Register::WSP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::UnsignedImmediate(i) = op {
if !(0..=4095).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.ldrsb_32_ldst_pos, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, 1)?;
if instr.op2().as_unsigned_immediate()? != 0 {
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, 2)?;
};
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_32_ldst_pos, instr, FormatterTextKind::BracketRight)?;;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Ldrsb32LdstPosAliases {
None,
}
pub struct Ldrsb64LdstPos;
impl Ldrsb64LdstPos {
pub fn mnemonic(_instr: &Instruction) -> Mnemonic {
Mnemonic::LDRSB
}
pub fn size(_instr: &Instruction) -> usize {
4
}
pub fn decode(data: u32, decoder: &mut Decoder) -> Result<Instruction> {
let imm12 = (data >> 10) & 4095;
let imm12_post = imm12;
let Rn = (data >> 5) & 31;
let Rn_post = Rn;
let Rt = (data >> 0) & 31;
let Rt_post = Rt;
let Rt_post = Rt;
let op_0 = Register::aarch64(Rt_post, false)?;
let Rn_post = Rn;
let op_1 = Register::aarch64(Rn_post, true)?;
let imm12_post = imm12;
let op_2 = imm12_post as u32;
let mut instr = Instruction::builder(Code::LDRSB_64_ldst_pos)
.operand(0, op_0)?
.operand(1, op_1)?
.operand(2, op_2)?
.build();
Ok(instr)
}
pub fn encode(instr: &Instruction, buf: &mut Vec<u8>) -> Result<usize> {
let Rt_pre = instr.op0().as_register()?.encode();
let Rn_pre = instr.op1().as_register()?.encode();
let imm12_pre = instr.op2().as_unsigned_immediate()? as u32;
let Rt = (Rt_pre & 31);
let Rn = (Rn_pre & 31);
let imm12_pre = imm12_pre;
let imm12 = (imm12_pre & 4095);
let mut instr: u32 = 0b00111001100000000000000000000000;
instr |= (Rt & 31) << 0;
instr |= (Rn & 31) << 5;
instr |= (imm12 & 4095) << 10;
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::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::SP {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op1(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::Register(r) = op {
if !r.is_aarch64() {
todo!()
}
if *r == Register::XZR {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op2(instr: &Instruction, op: &Operand) -> Result<()> {
if let Operand::UnsignedImmediate(i) = op {
if !(0..=4095).contains(i) {
todo!()
}
return Ok(())
}
todo!()
}
pub fn check_op3(instr: &Instruction, op: &Operand) -> Result<()> {
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.ldrsb_64_ldst_pos, instr)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, FormatterTextKind::Space)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, 0)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, FormatterTextKind::BracketLeft)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, 1)?;
if instr.op2().as_unsigned_immediate()? != 0 {
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, FormatterTextKind::Comma)?;
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, FormatterTextKind::NumSign)?;
fmt.format_operand(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, 2)?;
};
fmt.format_punctuation(output, &config.global, &config.instructions.ldrsb_64_ldst_pos, instr, FormatterTextKind::BracketRight)?;;
Ok(())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub enum Ldrsb64LdstPosAliases {
None,
}