beautypg.com

For/next, Applicable program areas operands, Flags function – Omron SYSMAC CP CP1E-N@@D@-@ User Manual

Page 92: 2 instructions, N: number of loops, Operand specifications

background image

2 Instructions

2-56

CP1E CPU Unit Instructions Reference Manual(W483)

FOR/NEXT

Applicable Program Areas

Operands

N: Number of loops

The number of loops must be 0000 to FFFF (0 to 65,535 decimal).

Operand Specifications

Flags

Function

Instruction

Mnemonic

Variations

Function

code

Function

---

FOR

---

512

The instructions between FOR(512) and
NEXT(513) are repeated a specified number of
times.

NEXT

---

513

Symbol

FOR

NEXT

Area

Step program areas

Subroutines

Interrupt tasks

Usage

---

OK

OK

Operand

Description

Data type

Size

N

Number of loops

UINT

1

Area

Word addresses

Indirect DM addresses

Constants

CF

Pulse bits

TR bits

CIO

WR

HR

AR

T

C

DM

@DM

*DM

N

OK

OK

OK

OK

OK

OK

OK

OK

OK

OK

---

---

---

Name

Label

Operation

Error Flag

P_ER

ON if more than 15 loops are nested.

OFF in all other cases.

Equals Flag

P_EQ

OFF

Negative Flag

P_N

OFF

The instructions between FOR(512) and NEXT(513)
are executed N times and then program execution con-
tinues with the instruction after NEXT(513). The
BREAK(514) instruction can be used to cancel the
loop.
If N is set to 0, the instructions between FOR(512) and
NEXT(513) are processed as NOP(000) instructions.
Loops can be used to process tables of data with a
minimum amount of programming.

FOR(512)

N

N: Number of loops

NEXT(513)

Repeated N times

Repeated program section

NEXT

FOR

N

This manual is related to the following products: