1. Division operation DIV/DIVW/DIVD

1. Division operation DIV/DIVW/DIVD

1.1. Instruction description

The instruction (DIV) divides two 16 bit integers and produces a result of * * 32-bit * , where the lower 16 bits store the quotient and the upper 16 bits store the remainder*

The instruction (DIVW) divides two 16 bit integers and produces a 16 bit quotient, with the remainder omitted.

The instruction (DIVD) divides two 32-bit integers and produces a 32-bit quotient.

Related registers Description
M8169 Operation overflow.
M8170 The result of the operation is negative.
M8171 The result of the operation is 0.
M8172 The divisor is zero.

1.2. The valid operands of the instruction

1.2.1. Single word division and remainder instruction(DIV)

Input/Output Data Type operand Description
IN1 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) Input 1
IN2 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) Input 2
OUT 32-bit integer D/CV, bit composite word (Y/M/C/T/S), local variable (LD) output

1.2.2. single word instruction(DIVW)

Input/Output Data Type operand Description
IN1 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) Input 1
IN2 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) Input 2
OUT 16 bit integer D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) output

1.2.3. Double word instruction(DIVD)

Input/Output Data Type operand Description
IN1 32-bit integer D/CV/K/H/FD, bit composite word (X/Y/M/C/T/S), local variable (LD) Input 1
IN2 32-bit integer D/CV/K/H/FD, bit composite word (X/Y/M/C/T/S), local variable (LD) Input 2
OUT 32-bit integer D/CV, bit composite word (Y/M/C/T/S), local variable (LD) output

1.3. Example

command table:

NETWORK 000

LD X000

DIV D0 D1 D2 // D0 ÷ D1 = D2D3 D2 storage integer, D3 storage remainder

DIV

图1 DIV