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§
Structs§
- Arm32
Double Precision Register - Arm32
MveVector Register - Arm32
Quadword Register - Arm32
Single Precision Register - ArmDecode
Context - 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§
- Arm32
Block Address Mode - Arm32
Condition - Arm32
CpsMode - Arm32
Directed Round - Arm32
Extend Type - Arm32
FpData Operation2 - Arm32
FpData Operation3 - Arm32
General Purpose Register - Arm32
Index Mode - Arm32
Instruction - The union of the two 32-bit ARM instruction sets.
ArmA32InstructionandArmT32Instructionare 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. - Arm32
LowGeneral Purpose Register - Arm32
Memory Offset - Arm32
Memory Offset8 - Arm32
MveBitwise Op - Arm32
MveFloat Arith Op - Arm32
MveFloat Reduce Op - Arm32
MveFloat Size - Arm32
MveInt Arith Op - Arm32
MveLong MacOp - Arm32
MveMisc2 Float Op - Arm32
MveMisc2 Op - Arm32
MveQ Movn Kind - Selects between VQMOVN (saturating narrow, signed or unsigned) and VQMOVUN (signed source, unsigned
saturated result). See
MVE_VQMOVN_BASE/MVE_VQMOVUN_BASE. - Arm32
MveReduce Op - Arm32
MveShift ImmOp - Arm32
MveShift Narrow Op - Arm32
MveSize - Arm32
MveVcmp Condition - Arm32
MveVec Scalar Float Op - Arm32
MveVec Scalar IntOp - Arm32
MveVrint Op - Arm32
Neon AesOp - Arm32
Neon Bitwise Op - Arm32
Neon Diff Long Op - Arm32
Neon Diff Narrow Op - Arm32
Neon Diff Wide Op - Arm32
Neon Float Op - Arm32
Neon Integer Op - Arm32
Neon Load Store Address - Arm32
Neon Misc2 Fixed Op - Arm32
Neon Misc2 Sized Op - Arm32
Neon Narrow Op - Arm32
Neon Scalar Long Op - Arm32
Neon Scalar Op - Arm32
Neon Sha2 Op - Arm32
Neon Sha3 Op - Arm32
Neon Shift Narrow Op - Arm32
Neon Shift Op - Arm32
Neon Size - Arm32
Parallel Operation - Arm32
Parallel Prefix - Arm32
Register Shift - Arm32
Shift Type - Arm32
Vmov Lane Size - The element width of a
VMOVcore <-> scalar-lane transfer (VMOV.<size> Dd[x], Rtand the reverse): the lane is a.8/.16/.32slice of a doubleword register. The width and the lane index are packed together into the encoding’sopc1([22:21]) andopc2([6:5]) fields – see the ARM ARM “VMOV (general-purpose register to scalar)” / “VMOV (scalar to general-purpose register)” descriptions (DDI0487 / DDI0553). - Arm32
Vrint Mode - Arm32
Vsel Condition - ArmA32
Instruction - ArmInstruction
Set - 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/BLXwhose target’s low bit picks the state). - ArmT32
CpsPrimask Effect - ArmT32
FpData Operation2 - ArmT32
FpData Operation3 - ArmT32
Index Mode - ArmT32
Instruction - ArmT32
Instruction Condition - ArmT32
Memory Barrier Option - ArmT32
Parallel Operation - ArmT32
Parallel Prefix - ArmT32
Register Shift - ArmT32
Special Register - Decode
Error - 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 isOk(None), not an error. - Encode
Error