Advanced Function Instruction
7-97
FUN111 D P
STACK
STACK
FUN111 D P
STACK
z When no data has yet been pushed into the stack or the pushed in data has already been popped out (Pr = 0),
the stack empty flag "EPT" will set to 1. In this case any further pop up actions, will be ignored. If more data is
pushed than popped out, sooner or latter the stack will be full (pointer Pr points to ST
L
position), and the stack
full flag "FUL" will set to 1. In this case any further push actions, will be ignored. As with queue, the stack
pointer in normal case should not be changed by other instructions. If there is a special application which
requires to set the Pr value, then its effective range is 0 to L (0 means empty, 1 to L respectively correspond to
ST
1
to ST
L
). Beyond this range, the pointer error flag "ERR" will set to 1, and the instruction will not be carried
out.
X0
EN
Pr :
R 20
L :
OW :
I/O
10
R 2
IW :
R 1
FUL
ERR
EPT
X1
R 0
111P.STACK
ST :
z The program at left assumes that the initial content of the
stack is just as in the diagram of a stack on the
preceding page. The operation illustrated in this example
is to push a data and than pop it from stack. The results
are shown below. Under any circumstances, Pr always
point to the data that was most recently pushed into the
stack.
Pr
Pr
5 R1 4
ST QU
ST1 1111 R2 ST1 1111 R2
ST2 2222 R3 ST2 2222 R3
ST3 3333 R4 ST3 3333 R4
ST4 4444 R5 OW ST4 4444 R5
OW
ST5 5555 R6 ××××
R20
ST5 R6
5555 R20
ST6 R7 ↑ ST6 R7
ST7 R8 OW unchanged ST7 R8
ST8 R9 ST8 R9
ST9 R10 ST9 R10
ST10 R11 ST10 R11
After push(X1=1,X0 from 0→1) After pop up(X1=0,X0 from 0→1)