beautypg.com

Application of sbn-ret and for-next instructions – KEYENCE Visual KV Series User Manual

Page 154

background image

2.4 Instruction Details

3-130

2

Chapter 2 Instructions

Application of SBN-RET and FOR-NEXT instructions

Data memory shift
Shifts the contents of the current data memory (DM) to the next DM at the rising
edge of the synchronous (timing) signal. As the number of DMs to be shifted in-
creases, the required scan time becomes longer.

Coding

0000

1000

2002

#00010

LDA

TM03

LDA

TM04

STA

TM02

SUB

TM05

STA

#00001

ADD

2002

TM03

DEC

#TM03

LDA

#TM04

STA

TM04

DEC

TM02

STA

#00030

TM03

LDA

STA

00

CALL

1000
DIFU

END

NEXT

SBN

00

FOR

2002

#00000

LDA

#TM02

STA

RET

TM05

ENDH

Synchronous
signal

Shift start DM
No. (DM0010)
is designated.

Shift end DM
No. (DM0030)
is designated.

Shift level

Indirect addressing is used
to designate DM Nos.

Program lines which execute
data shift are grouped as a
subroutine.

Data is shifted from DM0010 to
DM0030.

Shift start DM No. is cleared to
"#00000" after data is shifted.

Line No.

Instruction

Operand

Line No.

Instruction

Operand

0000

LD

0000

0020

STA

TM04

0001

DIFU

1000

0021

CON

0002

CON

0022

SUB

TM02

0003

AND

1000

0023

CON

0004

LDA

#00010

0024

STA

TM05

0005

CON

0025

FOR

TM05

0006

STA

TM02

0026

LD

2002

0007

CON

0027

DEC

TM03

0008

LDA

#00030

0028

CON

0009

CON

0029

DEC

TM04

0010

STA

TM03

0030

CON

0011

CON

0031

LDA

#TM03

0012

CALL

00

0032

CON

0013

END

0033

STA

#TM04

0014

SBN

00

0034

NEXT

0015

LD

2002

0035

LD

2002

0016

LDA

TM03

0036

LDA

#00000

0017

CON

0037

CON

0018

ADD

#00001

0038

STA

#TM02

0019

CON

0039

RET

0040

ENDH

FOR / NEXT

KVNKA Chap 02_4bP.p65

08.3.11, 0:00 PM

130