Lcal (label call), Lret (label return), Lcal (label call) -3 lret (label return) -3 – IDEC MicroSmart User Manual

Page 317

Advertising
background image

18: P

ROGRAM

B

RANCHING

I

NSTRUCTIONS

« FC4A M

ICRO

S

MART

U

SER

S

M

ANUAL

»

18-3

LCAL (Label Call)

Applicable CPU Modules

Valid Operands

For the valid operand number range, see pages 6-1 and 6-2.

Since the LCAL instruction is executed in each scan while input is on, a pulse input from a SOTU or SOTD instruction
should be used as required.

Note: Make sure that a LABEL instruction of the label number used for a LCAL instruction is programmed. When designating
S1 using other than a constant, the value for the label is a variable. When using a variable for a label, make sure that all
probable LABEL numbers are included in the user program. If a matching label does not exist, a user program execution
error will result, turning on special internal relay M8004 and the ERR LED on the CPU module.

LRET (Label Return)

Applicable CPU Modules

Valid Operands

FC4A-C10R2/C

FC4A-C16R2/C

FC4A-C24R2/C

FC4A-D20K3/S3

FC4A-D20RK1/RS1 & FC4A-D40K3/S3

X

X

X

X

X

Operand

Function

I

Q

M

R

T

C

D

Constant

Repeat

S1 (Source 1)

Label number to call

X

0-127

FC4A-C10R2/C

FC4A-C16R2/C

FC4A-C24R2/C

FC4A-D20K3/S3

FC4A-D20RK1/RS1 & FC4A-D40K3/S3

X

X

X

X

X

Operand

Function

I

Q

M

R

T

C

D

Constant

Repeat

When input is on, the address with label 0 through 127 designated by S1 is called. When
input is off, no call takes place, and program execution proceeds with the next instruc-
tion.

The LCAL instruction calls a subroutine, and returns to the main program after the branch
is executed. A LRET instruction (see below) must be placed at the end of a program
branch which is called, so that normal program execution resumes by returning to the
instruction following the LCAL instruction.

Note: The END instruction must be used to separate the main program from any subrou-
tines called by the LCAL instruction.

A maximum of four LCAL instructions can be nested. When more than four LCAL instruc-
tions are nested, a user program execution error will result, turning on special internal
relay M8004 and the ERR LED on the CPU module.

LCAL

S1

*****

This instruction is placed at the end of a subroutine called by the LCAL instruction. When the subrou-
tine is completed, normal program execution resumes by returning to the instruction following the
LCAL instruction.

The LRET must be placed at the end of the subroutine star ting with a LABEL instruction. When the
LRET is programmed at other places, a user program execution error will result, turning on special
internal relay M8004 and the ERR LED on the CPU module.

LRET

Advertising