13.07.2015 Views

[Instruction] Contents

[Instruction] Contents

[Instruction] Contents

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Advanced Function <strong>Instruction</strong>FUN111 D PSTACKSTACKFUN111 D PSTACKExecution controlENIn/Out control I/O L :Ladder symbol111DP.STACKIW :ST :Pr :OW :EPTFULERRStack emptyStack fullPointer errorIW : Data pushed into stack, can be a constantor a registerST : Starting register of stackL : Size of stackPr : Pointer registerOW : Register accepting data popped out fromstackST may combine with V, Z, P0~P9 to serveindirect address applicationOperandRangeWX WY WM WS TMR CTR HR IR OR SR ROR DR K XRWX0∣WX240WY0∣WY240WM0∣WM1896WS0∣WS984T0∣T255C0∣C255R0∣R3839R3840∣R3903R3904∣R3967R3968∣R4167R5000∣R8071D0∣D409516/32-bit+/-numberIW ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ST ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○L ○ ○* ○ 2~256Pr ○ ○ ○ ○ ○ ○ ○ ○* ○* ○OW ○ ○ ○ ○ ○ ○ ○ ○* ○* ○V、ZP0~P9• Like queue, stack is also a kind of table. The nature of its pointer is exactly the same as with queue, i.e. Pr = 1to L, which corresponds to ST 1 to ST L, and when Pr = 0 the stack is empty.• Stack is the opposite of queue, being a last in first out (LIFO) device. This means that the data that was mostrecently pushed into the stack will be the first to be popped out of the stack. The stack is comprised of Lconsecutive 16 or 32-bit ( D instruction) registers starting from ST, as shown in the following diagram:~ is the sequencenumber of operationPr4STST1 1111 ← Bottom of stackST2 2222ST3 3333IW ST4 4444 OW5555 ST5 ××××push(I/O=1)pushpop(I/O=0)1.Pr+1→Pr2.IW→STprSTL1.STpr→OW2.Pr-1→Pr• When execution control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, the status of in/outcontrol "I/O" determines whether the IW data will be pushed into the stack (when "I/O" = 1), or the data pointedby Pr within the stack (the data most recently pushed into the stack) will be moved out and transferred to OW(when "I/O" = 0). Note that the data pushed in is stacking, so before pushed in, Pr will increased by 1 to pointto the top of the stack then the data will be pushed in. When it is popped out, the data pointed by pointer Pr(the most recently pushed in data) will be transferred to OW. After then Pr will decreased by 1. Under anycircumstances, the pointer Pr will always point to the data that was pushed into the stack most recently.7-96

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!