5 Categories and Use of Basic Application Instructions API D 23 Operands: S 1 : Dividend S 2 : Divisor D : Quotient and remainder Explanations: 1. DIV instruction divides S 1 and S 2 in BIN format and stores the result in D . Care should be taken on positive/negative signs of S 1 , S 2 and D when doing 16-bit and 32-bit operations. 2. When DIV is used as 16-bit instruction, Z device cannot be adopted; when DIV is used as 32-bit instruction, V device cannot be adopted. 3. DIV will not be executed when the divisor is 0. 4. In 16-bit BIN division: Quotient Remainder S 1 S 2 +1 = / 5. In 32-bit BIN division: Quotient Remainder +1 +1 +3 +2 S 1 S 2 S 1 S 2 +1 / = Program Example:
When X0 = ON, D0 will be divided by D10, and the quotient will be stored in D20 while remainder in D21. ON/OFF of MSB indicates the positive/negative status of the result. X0 DVP-PM Operation Instruction 5-40 Operands Function Controllers 20PM 10PM DIV P Division Type OP Bit Devices Word Devices Program Steps X Y M S K H KnX KnY KnM KnS T C D V Z DIV, DIVP: 7 steps DDIV, DDIVP: 9 steps S 1 * * * * * * * * * * * D S 2 * * * * * * * * * * * D * * * P D DIV D0 D10 D20 DIV D0 D10 K4Y0