DVP - ES2/EX2/SS2/SA2/SX2/SE Operation Manual - Programming

API

23

Mnemonic

Operands

Function

Controllers

D

DIV

P

Division

ES2/EX2

SS2

SA2

SX2

SE

Type

 

Bit Devices

 

 

 

 

Word devices

 

 

 

 

 

 

Program Steps

 

OP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

Y

M

S

 

K

H

KnX

KnY

KnM

KnS

T

C

D

E

F

DIV, DIVP: 7 steps

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

S1

 

 

 

 

 

 

*

*

*

*

*

*

*

*

*

 

*

 

DDIV, DDIVP: 13 steps

S2

 

 

 

 

 

 

*

*

*

*

*

*

*

*

 

*

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

D

 

 

 

 

 

 

 

 

 

*

*

*

*

*

*

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PULSE

 

 

 

16-bit

 

 

 

 

32-bit

 

 

 

 

 

 

 

 

ES2/EX2

SS2

SA2

SX2

ES2/EX2

SS2

 

SA2

SX2

ES2/EX2

SS2

 

SA2

SX2

 

 

 

 

 

 

SE

 

SE

 

SE

Operands:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

S1: Dividend

 

S2: Divisor

 

D: Quotient and remainder

 

 

 

 

 

 

 

 

 

 

 

Explanation:

1.This instruction divides S1 and S2 in BIN format and stores the result in D. Care should be taken on positive/negative signs of S1, S2 and D when doing 16-bit and 32-bit operations.

2.This instruction will not be executed when the divisor is 0. M1067 and M1068 will be ON and D1067 records the error code 0E19 (hex).

3.If operands S1, S2 use index F, then only 16-bit instruction is available.

4.If operand D use index E, then only 16-bit instruction is available.

5.16-bit BIN division:

 

 

 

 

Quotient

Remainder

S1

 

S2

 

 

D

D

+1

b15

b00

b15

b00

b15

.............b00

b15

b00

 

 

/

 

=

 

 

 

If D is specified with a bit device, it can designate K1 ~ K4 to store a 16-bit result. Users can use consecutive 2 16-bit registers to store 32-bit data of the quotient and remainder.

6. 32-bit BIN division:

 

 

Quotient

Remainder

S1 +1 S1

S2 +1 S2

D +1

D

D +3 D +2

b15..b00 b15..b00

b15..b00 b15..b00

b31..b16 b15..b00

b31..b16 b15..b00

/

 

=

 

 

If D is specified with a bit device, it can designate K1 ~ K8 to store a 32-bit result. Users can use consecutive 2 32-bit registers to store the quotient and remainder.

Program Example:

When X0 = ON, D0 will be divided by D10 and the quotient will be stored in D20 and remainder in D21. ON/OFF of the MSB indicates the positive/negative status of the result value..

X0

DIV

D0

D10

D20

3 - 80

Page 196
Image 196
Delta DVP-ES2/EX2/SS2/SA2/SX2/SE manual Div, B00 B15