Skip to main content

Crate scaleservers_arm32_assembly

Crate scaleservers_arm32_assembly 

Source
Expand description

ARM 32-bit assembly encode/decode library – the ARM32 member of the scaleservers assembler family (the 32-bit sibling of scaleservers-arm64-assembly).

There are two central models, kept as separate types so a compiler backend cannot mix the two instruction sets within one code stream: ArmT32Instruction (Thumb / T32 – the full M-profile set: ARMv6-M, ARMv7-M, ARMv7E-M DSP + hardware floating point, the ARMv8-M Security Extension, and the complete ARMv8.1-M MVE/“Helium” vector extension) and ArmA32Instruction (ARM state / A32 – the A/R-profile set including NEON + VFP). Arm32Instruction is the interworking union of both. Every instruction offers the family signatures: encode (model -> machine bytes), decode (bytes -> model, the exact inverse of encode), encode_for_target(&ArmTargetProfile) (target/ISA gating – refuses forms the chosen CPU cannot run), and to_assembly_string(syntax) (model -> UAL text, in LLVM or GNU flavor). The console armasm (assembler) and armdasm (disassembler) are thin tools over this library.

Decoding never panics on arbitrary input – malformed bytes yield a DecodeError, never a crash (a disassembler consumes untrusted binaries); this is enforced by deterministic robustness sweeps and a cargo-fuzz campaign.

use scaleservers_arm32_assembly::{ArmT32Instruction, ArmAssemblySyntax};

// model -> machine bytes (Thumb is little-endian; NOP is the halfword 0xBF00)
let nop = ArmT32Instruction::Nop_T1;
assert_eq!(nop.encode().unwrap(), [0x00, 0xbf]);

// model -> UAL assembly text
assert_eq!(nop.to_assembly_string(ArmAssemblySyntax::Gnu), "nop");

// machine bytes -> model (decode is the exact inverse of encode)
let bytes = [0x00u8, 0xbf];
let mut offset = 0;
let decoded = ArmT32Instruction::decode(&mut bytes.iter(), &mut offset).unwrap().unwrap();
assert_eq!(decoded, nop);

Re-exports§

pub use floating_point_immediate::vfp_encode_f64_to_imm8;
pub use floating_point_immediate::vfp_expand_imm8_to_f32;
pub use floating_point_immediate::vfp_expand_imm8_to_f64;
pub use emit::ArmAssemblySyntax;
pub use emit::apply_it_block_condition;
pub use emit::apply_vpt_block_suffix;
pub use targets::ArmCpuFeature;
pub use targets::ArmInstructionRequirement;
pub use targets::ArmIsaVersion;
pub use targets::ArmTargetProfile;

Modules§

emit
floating_point_immediate
targets

Structs§

Arm32DoublePrecisionRegister
Arm32MveVectorRegister
Arm32QuadwordRegister
Arm32SinglePrecisionRegister
ArmDecodeContext
Decode-time context for resolving the one T32 “same bytes, different meaning” ambiguity – the family-wide Rule R4: disambiguate by an explicit decode context, never by guessing.

Enums§

Arm32BlockAddressMode
Arm32Condition
Arm32CpsMode
Arm32DirectedRound
Arm32ExtendType
Arm32FpDataOperation2
Arm32FpDataOperation3
Arm32GeneralPurposeRegister
Arm32IndexMode
Arm32Instruction
The union of the two 32-bit ARM instruction sets. ArmA32Instruction and ArmT32Instruction are kept as SEPARATE types so a compiler backend cannot accidentally mix sets within one stream (the wrong-set mistake becomes a compile error, not a runtime one). This enum re-unites them for the disassembler, which must follow ARM/Thumb interworking across a single binary, and for any caller that genuinely handles both states.
Arm32LowGeneralPurposeRegister
Arm32MemoryOffset
Arm32MemoryOffset8
Arm32MveBitwiseOp
Arm32MveFloatArithOp
Arm32MveFloatReduceOp
Arm32MveFloatSize
Arm32MveIntArithOp
Arm32MveLongMacOp
Arm32MveMisc2FloatOp
Arm32MveMisc2Op
Arm32MveQMovnKind
Selects between VQMOVN (saturating narrow, signed or unsigned) and VQMOVUN (signed source, unsigned saturated result). See MVE_VQMOVN_BASE/MVE_VQMOVUN_BASE.
Arm32MveReduceOp
Arm32MveShiftImmOp
Arm32MveShiftNarrowOp
Arm32MveSize
Arm32MveVcmpCondition
Arm32MveVecScalarFloatOp
Arm32MveVecScalarIntOp
Arm32MveVrintOp
Arm32NeonAesOp
Arm32NeonBitwiseOp
Arm32NeonDiffLongOp
Arm32NeonDiffNarrowOp
Arm32NeonDiffWideOp
Arm32NeonFloatOp
Arm32NeonIntegerOp
Arm32NeonLoadStoreAddress
Arm32NeonMisc2FixedOp
Arm32NeonMisc2SizedOp
Arm32NeonNarrowOp
Arm32NeonScalarLongOp
Arm32NeonScalarOp
Arm32NeonSha2Op
Arm32NeonSha3Op
Arm32NeonShiftNarrowOp
Arm32NeonShiftOp
Arm32NeonSize
Arm32ParallelOperation
Arm32ParallelPrefix
Arm32RegisterShift
Arm32ShiftType
Arm32VmovLaneSize
The element width of a VMOV core <-> scalar-lane transfer (VMOV.<size> Dd[x], Rt and the reverse): the lane is a .8/.16/.32 slice of a doubleword register. The width and the lane index are packed together into the encoding’s opc1 ([22:21]) and opc2 ([6:5]) fields – see the ARM ARM “VMOV (general-purpose register to scalar)” / “VMOV (scalar to general-purpose register)” descriptions (DDI0487 / DDI0553).
Arm32VrintMode
Arm32VselCondition
ArmA32Instruction
ArmInstructionSet
Which ARM instruction set a code stream is in. A32 (“ARM” state) and T32 (Thumb state) are distinct instruction sets with incompatible encodings; a 32-bit ARM program selects between them at runtime (interworking – a BX/BLX whose target’s low bit picks the state).
ArmT32CpsPrimaskEffect
ArmT32FpDataOperation2
ArmT32FpDataOperation3
ArmT32IndexMode
ArmT32Instruction
ArmT32InstructionCondition
ArmT32MemoryBarrierOption
ArmT32ParallelOperation
ArmT32ParallelPrefix
ArmT32RegisterShift
ArmT32SpecialRegister
DecodeError
Errors returned by the decode paths (ArmT32Instruction::decode / ArmA32Instruction::decode) when the input bytes are not well-formed. Decoding NEVER panics on arbitrary input: every malformation is surfaced as one of these variants, because a disassembler consumes untrusted binaries and must report bad bytes, not crash. A clean end-of-input at an instruction boundary is Ok(None), not an error.
EncodeError

Functions§

mve_predicate_mask_from_suffix