8: ADVANCED INSTRUCTIONS
8-4 USER’S MANUAL
Structure of an Advanced Instruction
Input Condition for Advanced Instructions
Almost all advanced instructions must be preceded by a contact, except NOP (no operation) and HSC0 through HSC3
(high-speed counter) instructions. The input condition can be programmed using a bit operand such as input, output, inter-
nal relay, or shift register. Timer and counter can also be used as an input condition to turn on the contact when the timer
times out or the counter counts out.
While the input condition is on, the advanced instruction is exe-
cuted in each scan. To execute the advanced instruction only at
the rising or falling edge of the input, use the SOTU or SOTD
instruction.
Source and Destination Operands
The source and destination operands specify 16-bit word data. When a bit operand such as input, output, internal relay, or
shift register is designated as a source or destination operand, 16 points starting with the designated number are processed
as source or destination data. When a word operand such as timer or counter is designated as a source operand, the current
value is read as a source data. When a timer or counter is designated as a destination operand, the result of the advanced
instruction is set to the preset value for the timer or counter. When a data register is designated as a source or destination
operand, the data is read from or written to the designated data register.
Using Timer or Counter as Source Operand
Since all timer instructions—TIM (100-msec timer), TMH (10-msec timer), and TMS (1-msec timer)—subtract from the
preset value, the current value is decremented from the preset value and indicates the remaining time. As described above,
when a timer is designated as a source operand of an advanced instruction, the current value, or the remaining time, of the
timer is read as a source data. Reversible counters C0 and C1 start counting at the preset value and the current value is
incremented or decremented from the preset value. Adding counters C2 through C31 start counting at 0, and the current
value is incremented up to the preset value. When any counter is designated as a source operand of an advanced instruc-
tion, the current value is read as a source data.
Using Timer or Counter as Destination Operand
As described above, when a timer or counter is designated as a destination operand of an advanced instruction, the result
of the advanced instruction is set to the preset value of the timer or counter. Since timer and counter preset values can be 0
through 9999, make sure that the result of the advanced instruction does not exceed 9999. If the result to be set to a timer
or counter designated as destination exceeds 9999, a user program execution error will result, then error indicator ERR1 is
lit and special internal relay M304 turns on.
When a timer or counter preset value is designated using a data register, the timer or counter cannot be designated as a des-
tination of an advanced instruction. When executing such an advanced instruction, a user program execution error will
result. If a timer or counter is designated as a destination of an advanced instruction and if the timer or counter is not pro-
grammed, then a user program execution error will also result. For details of user program execution error, see page 18-5.
Note: When a user program execution error occurs, the result is not set to the destination.
Repeat Designation
Specifies whether repeat is used for the operand or not.
Repeat Cycles
Specifies the quantity of repeat cycles: 1 through 31.
I0
MOV S1 R
*****
REP
**
D1 R
****
Opcode
The opcode is a symbol to identify the advanced instruction.
Source Operand
The source operand specifies the 16-bit word data to be pro-
cessed by the advanced instruction. Some advanced instruc-
tions require two source operands.
Destination Operand
The destination operand specifies the 16-bit word data to
store the result of the advanced instruction. Some advanced
instructions require two destination operands.
Opcode
Source Operand
Repeat Cycles
Destination Operand
Repeat Designation
I0
MOV REP
**
S1
D10
D1
D20
SOTU