379
Special Instructions
Section 5-28
5-27-2 SUBROUTINE DEFINE and RETURN – SBN(92)/RET(93)
Limitations
Each subroutine number can be used in SBN(92) only once.
Description
SBN(92) is used to mark the beginning of a subroutine program; RET(93) is
used to mark the end. Each subroutine is identified with a subroutine number,
N, that is programmed as a definer for SBN(92). This same subroutine num-
ber is used in any SBS(91) that calls the subroutine (see
5-27-1 SUBROU-
TINE ENTER – SBS(91)
. No subroutine number is required with RET(93).
All subroutines must be programmed at the end of the main program. When
one or more subroutines have been programmed, the main program will be
executed up to the first SBN(92) before returning to address 00000 for the
next cycle. Subroutines will not be executed unless called by SBS(91).
END(01) must be placed at the end of the last subroutine program, i.e., after
the last RET(93). It is not required at any other point in the program.
Precautions
If SBN(92) is mistakenly placed in the main program, it will inhibit program
execution past that point, i.e., program execution will return to the beginning
when SBN(92) is encountered.
If either DIFU(13) or DIFU(14) is placed within a subroutine, the operand bit
will not be turned OFF until the next time the subroutine is executed, i.e., the
operand bit may stay ON longer than one cycle.
Flags
There are no flags directly affected by these instructions.
5-28 Special Instructions
5-28-1 TRACE MEMORY SAMPLING – TRSM(45)
Data tracing can be used to facilitate debugging programs. To set up and use
data tracing it is necessary to have a host computer running SSS; no data
tracing is possible from a Programming Console. Data tracing is described in
detail in the
SSS Operation Manual: C-series PCs
. This section shows the
ladder symbol for TRSM(45) and gives an example program.
Description
TRSM(45) is used in the program to mark locations where specified data is to
be stored in Trace Memory. Up to 12 bits and up to 3 words may be desig-
nated for tracing. (Refer to the
CX-Programmer Operation Manual
for details.)
TRSM(45) is not controlled by an execution condition, but rather by two bits in
the AR area: AR 2515 and AR 2514. AR 2515 is the Sampling Start bit. This
bit is turned ON to start the sampling processes for tracing. The Sampling
Start bit must not be turned ON from the program, i.e., it must be turned ON
only from the peripheral device. AR 2514 is the Trace Start bit. When it is set,
N
:
Subroutine number
000 to 255
SBN(92) N
Ladder Symbols
Definer Data Areas
RET(93)
Ladder Symbol
TRSM(45)