beautypg.com

Add (addition) – KEYENCE Visual KV Series User Manual

Page 175

background image

2.4 Instruction Details

1

2

3-151

Chapter 2 Instructions

ADD (Addition)

Coding

Description

The ADD instruction adds the operand value to the contents of the internal
register and inputs the result back to the internal register.

In the above example, "#00100" is added to the contents of DM0000 and the
result is stored in DM0001.

When the contents of DM0000 is "#00100", for example, "#00200" is stored in
DM0001.
DM0000 (#00100) + #00100 → DM0001(#00200)

Note 1: An overflow occurs when the operation result exceeds 16 bits ($FFFF,
#65535). In such a case, only the data of the low-order 16 bits is input back to the
internal register. For example, when the contents of the internal register is "$FFFF"
and the operand is "$0001", the result will overflow.

Note 2: When an overflow occurs, special utility relay 2009 turns ON.

Tips

Solution when operation result overflows 16 bits

DM0000 + DM0001 = DM0003 (High-order 16 bits), DM0002 (Low-order 16 bits)
DM0000 and DM0001 must be 16 bits or less.

Arithmetic flag

2009

Turns ON when the result of an ADD operation exceeds the range of 16 bits
($FFFF). Turns OFF at other times.

2010

Turns ON when the contents of the internal register is "0" after an ADD
operation. Turns OFF at other times.

2011

No change

2012

The DM or relay indirectly addressed with #TM is out of range.

➮ "Indirect addressing" (p. 3-127)

DM0000

LDA

#00100

ADD

DM0001

STA

2002

Line No.

Instruction

Operand

0000

LD

2002

0001

LDA

DM0000

0002

CON

0003

ADD

#00100

0004

CON

0005

STA

DM0001

Example:
Internal register

1

1

= $FFFF

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

0

+

= $0002

0 0 0 0 0 0 0 0 0 0 0 0 0 1 0

0

= $0001

2009

0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

Operand

Overflow

Special
utility relay

Input back internal register

Result

DM0000

LDA

DM0001

ADD

DM0002

STA

#00000

LDA

DM0003

STA

DM0002

STA

#00001

LDA

DM0003

STA

2002

2009

2009

ADD / @ADD

KVNKA Chap 02_4cP.p65

08.3.11, 0:02 PM

151