sdiv

Signed Divide (Thumb)

SDIV <Rd>, <Rn>, <Rm>

Signed integer division.

Details

Perform signed integer division of Rn by Rm and place the quotient in Rd. If Rm is zero, the result is UNPREDICTABLE. If overflow occurs (e.g., INT_MIN / -1), the result is UNPREDICTABLE. No condition flags are affected. This instruction is available in T32 (Thumb) and executes in all privilege levels.

Pseudocode Operation

if Rm == 0 then UNPREDICTABLE else Rd ← SignedDivide(Rn, Rm)

Example

SDIV r0, r1, r2

Encoding

Binary Layout
111110111
001
Rn
1111
Rd
1111
Rm
 
Format Thumb Div
Opcode 0xFB90F0F0
Extension A32 (Base)

Operands

  • Rd
    Destination general-purpose register
  • Rn
    Dividend
  • Rm
    Divisor

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x0710F010 SDIV{<c>}{<q>} {<Rd>,} <Rn>, <Rm> A32 cond | 01110 | 001 | Rd | 1111 | Rm | 000 | 1 | Rn
0xFB90F0F0 SDIV{<c>}{<q>} {<Rd>,} <Rn>, <Rm> T32 111110111 | 001 | Rn | 1111 | Rd | 1111 | Rm

Description

Signed Divide divides a 32-bit signed integer register value by a 32-bit signed integer register value, and writes the result to the destination register. The condition flags are not affected.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    integer result;
    if SInt(R[m]) == 0 then
        result = 0;
    else
        result = RoundTowardsZero(Real(SInt(R[n])) / Real(SInt(R[m])));
    R[d] = result<31:0>;