3. Instructions
558
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Flags
Function
PUSH(632) writes the content of S to the address indicated by the stack pointer (TB+3 and TB+2) and
increments the stack pointer by one.
The stack must be defined in advance with SSET(630).
Hint
• After data is stored with this instruction, the stack pointer specifies the next address after the last data
word.
• After PUSH(632) has been used to write data into a stack, FIFO(633) and LIFO(634) can be used to
read data from the stack.
Example Programming
When CIO 0.00 is ON in the following example, PUSH(632) copies the content of D200 to the stack
beginning at D0. In this case, the stack pointer indicates D7.
Name Label Operation
Error Flag ER • ON if the address specified by the stack pointer (TB+3 and TB+2) exceeds the last word in the stack.
(This is a stack overflow error.)
• OFF in all other cases.
m
n
n
m
D
D+1
D+2
D+3
S
m
m+1
n
n
m+1
D
D+1
D+2
D+3
A
A
A
PLC memory
address
PLC memory
address
Write A.
Pointer
Increment
pointer by 1.
Pointer
PC memory address
Write A.
Last word
in stack
Stack
pointer
PC memory address
of last word in stack
Stack pointer
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
0.00
D0
D200
D200
A
PC memory address
After the data is written to
D7, the stack pointer is
incremented by one.
PC memory address
of last word in stack
Stack pointer
Last word
in stack
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9