Delta AH500 — 6.2.2 Explanation of Arithmetic Instructions

Chapter 6 Applied Instructions Symbol: S 1 : Minuend Word/Double word S 2 : SubtrAH500end Word/Double word D : Difference Word/Double word Explanation: 1. The binary value in S 2 is subtracted from the binary value in S 1 , and the difference is stored in D . 2. Only the 32-bit instructions can use the 32-bit counter. 3. The Flags: SM600 (zero flag), SM601 (borrow flag), and SM602 (carry flag) 4. When the operation result is zero, SM600 is ON. Otherwise, it is OFF. 5. When a borrow occurs during the arithmetic, SM601 is ON. Otherwise, it is OFF. Example 1: The subtraction of 16-bit binary values:

When X0.0 is ON, the subtrAH500end in D10 is subtracted from the minuend in D0, and the difference is stored in D20.  When the values in D0 and D10 are 100 and 10 respectively, D0 minus D10 leaves 90, and 90 is stored in D20.  When the values in D0 and D10 are 16#8000 and 16#1 respectively, D0 minus D10 leaves 16#7FFF, and 16#7FFF is stored in D20.  When the values in D0 and D10 are 16#1 and 16#2 respectively, D0 minus D10 leaves 16#FFFF. Since the borrow occurs during the arithmetic, SM601 is ON, and the value stored in D20 is 16#FFFF.  When the values in D0 and D10 are 16#0 and 16#FFFF respectively, D0 minus D10 leaves 16#F0001.

Since the borrow occurs during the arithmetic, SM601 is ON, and the value stored in D20 is 16#1. 6-39 API Instruction code Operand Function 0101 D - P S , S , D 1 2 Subtraction of binary numbers Device X Y M S T C HC D L SM SR E PR K 16# “$” DF S 1             S 2             D           Pulse instruction 16-bit instruction (7 steps) 32-bit instruction (7 steps) AH500 AH500 AH500