Chapter 4. Ladder Diagram (LD) Programming182 PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual GFK-2950C4.9.5 LIFO ReadThe Last-In-First-Out (LIFO) Read (LIFO_RD) function moves data outof tables. Values are always moved out of the top of the table. If thepointer reaches the last location and the table becomes full, LIFO_RDmust be used to remove the entry at the pointer location anddecrement the pointer by one. LIFO_RD is used in conjunction with theLIFO_WRT function, which increments the pointer and writes entriesinto the table.Mnemonics:LIFO_RD_DINTLIFO_RD_DWORDLIFO_RD_INTLIFO_RD_UINTLIFO_RD_WORD1. LIFO_RD copies data indicated by the pointer to output parameter Q. Additional program logicmust then be used to place the data in the input reference.2. LIFO_RD decrements the pointer by one.3. Steps 1 and 2 are repeated each time the instruction is executed, until the table is empty (PTR =LEN).The pointer does not wrap around when the table is full.When LIFO_RD receives power flow, the data at the pointer location is copied to output Q, then thepointer is decremented. If this causes the pointer location to become 0, the output EM is set ON, i.e.,EM indicates whether or not the table is empty. If the table is empty when LIFO_RD receives powerflow, no read occurs. The pointer always indicates the last item entered into the table.LIFO_RD passes power to the right if the pointer was in range for an element to be read.Note: A LIFO table is a stack. A FIFO table is a queue.Operands for LIFO ReadNote: For each mnemonic, use the corresponding data type for the TB and Q operands. Forexample, LIFO_RD_DINT requires TB and Q to be DINT variables.Parameter Description Allowed Operands OptionalLength (??) 1 Length 32,767. Constant NoTB (must be the sametype as Q)The elements in the table All except constants NoPTR Pointer. Index of the nextelement to read.All except constants, S - SC, and data flow NoEM Energized when the lastelement of the table is readPower flow NoQ (must be the sametype as TB)The element read from thetableAll except constants and S. SA, SB, SCallowed only for WORD, DWORD.NoExample for LIFO ReadPRODUCT is a LIFO table with 100 word-sized elements. Whenthe enabling input PACK_IT is ON, the data item at the top of thetable is copied into the reference indicated by the nicknameCART. The reference identified by STK_PTR contains the tablepointer. Output coil EMPTY indicates when the table is empty.