A maior rede de estudos do Brasil

Grátis
LogixProCCZF

Pré-visualização | Página 41 de 50

S:0/0 Carry (C) always resets.
S:0/1 Overflow (V) always resets.
S:0/2 Zero (Z) sets if result is zero; otherwise resets.
S:0/3 Sign (S) sets if result is negative (most significant bit is set); otherwise
resets.
3333 333
NOT
NOT
Source
Dest
Output Instruction
PrefaceInstruction Set Reference Manual
4–26
Negate (NEG)
Use the NEG instruction to change the sign of the source and then place it in the
destination. The destination contains the two’s complement of the source. For
example, if the source is 5, the destination would be –5.
The source and destination must be word addresses.
Updates to Arithmetic Status Bits
With this Bit: The Controller:
S:0/0 Carry (C) clears if 0 or overflow, otherwise sets.
S:0/1 Overflow (V)
sets if overflow, otherwise reset. Overflow occurs only if
–32,768 is the source. On overflow, the minor error flag is also
set. The value 32,767 is placed in the destination. If S:2/14 is
set, then the unsigned, truncated overflow remains in the
destination.
For floating point destinations, the overflow result remains in
the destination.
S:0/2 Zero (Z) sets if result is zero; otherwise resets.
S:0/3 Sign (S) sets if result is negative; otherwise resets.
3333 333
NEG
NEGATE
Source
Dest
Output Instruction
Data Handling Instructions
4–27
FIFO and LIFO Instructions Overview
FIFO instructions load words into a file and unload them in the same order as they
were loaded. The first word in is the first word out.
LIFO instructions load words into a file and unload them in the opposite order as
they were loaded. The last word in is the first word out.
Entering Parameters
Enter the following parameters when programming these instructions:
• Source is a word address or constant (–32,768 to 32,767) that becomes the next
value in the stack.
• Destination is a word address that stores the value that exits from the stack.
This Instruction: Unloads the Value from:
FIFO’s FFU First word
LIFO’s LFU The last word entered
• FIFO/LIFO is the address of the stack. It must be an indexed word address in
the bit, input, output, or integer file. Use the same FIFO address for the
associated FFL and FFU instructions; use the same LIFO address for the
associated LFL and LFU instructions.
• Length specifies the maximum number of words in the stack. For SLC
processors this is 128 words and 105 words for MicroLogix 1000 controllers.
Address the length value by mnemonic (LEN).
• Position is the next available location where the instruction loads data into the
stack. This value changes after each load or unload operation. Address the
position value by mnemonic (POS).
• Control is a control file address. The status bits, the stack length, and the
position value are stored in this element. Do not use the control file address for
any other instruction.
PrefaceInstruction Set Reference Manual
4–28
Status bits of the control structure are addressed by mnemonic. These include:
– Empty Bit EM (bit 12) is set by the processor to indicate the stack is
empty.
– Done Bit DN (bit 13) is set by the processor to indicate the stack is full.
This inhibits loading the stack.
– FFU/LFU Enable Bit EU (bit 14) is set on a false-to-true transition of the
FFU/LFU rung and is reset on a true-to-false transition.
– FFL/LFL Enable Bit EN (bit 15) is set on a false-to-true transition of the
FFL/LFL rung and is reset on a true-to-false transition.
Effects on Index Register S:24
The value present in S:24 is overwritten with the position value when a false-to–true
transition of the FFL/FFU or LFL/LFU rung occurs. For the FFL/LFL, the position
value determined at instruction entry is placed in S:24. For the FFU/LFU, the
position value determined at instruction exit is placed in S:24.
When the DN bit is set, a false-to–true transition of the FFL/LFL rung does not
change the position value or the index register value. When the EM bit is set, a
false-to–true transition of the FFU/LFU rung does not change the position value or
the index register value.
Data Handling Instructions
4–29
FIFO Load (FFL) and FIFO Unload (FFU)
FFL and FFU instructions are used in pairs. The FFL instruction loads words into a
user-created file called a FIFO stack. The FFU instruction unloads words from the
FIFO stack, in the same order as they were entered.
Instruction parameters have been programmed in the FFL–FFU instruction pair
shown below.
(EU)
(EM)
(DN)
FFL
FIFO LOAD
Source N7:10
FIFO #N7:12
Control R6:0
Length 34
Position 9
FFU
FIFO UNLOAD
FIFO #N7:12
Dest N7:11
Control R6:0
Length 34
Position 9
FFU instruction unloads data
from stack #N7:12 at position 0,
N7:12.
N7:12 0
N7:13 1
N7:14 2
3
4
5
6
7
8
9
33
34 words are allocated
for FIFO stack starting at
N7:12, ending at N7:45.
FFL–FFU Instruction Pair
Loading and Unloading of Stack #N7:12
N7:10
N7:11
PositionDestination
Source
FFL instruction loads data into
stack #N7:12 at the next available
position, 9 in this case.
N7:45
(EN)
(DN)
(EM)
FFL Instruction Operation: When rung conditions change from false-to-true, the
FFL enable bit (EN) is set. This loads the contents of the source, N7:10, into the
stack element indicated by the position number, 9. The position value then
increments.
The FFL instruction loads an element at each false-to-true transition of the rung,
until the stack is filled (34 elements). The processor then sets the done bit (DN),
inhibiting further loading.
FFU Instruction Operation: When rung conditions change from false-to-true, the
FFU enable bit (EU) is set. This unloads the contents of the element at stack
position 0 into the destination, N7:11. All data in the stack is shifted one element
toward position zero, and the highest numbered element is zeroed. The position
value then decrements.
The FFU instruction unloads an element at each false–to-true transition of the rung,
until the stack is empty. The processor then sets the empty bit (EM).
33 333
(EN)
(DN)
(EM)
FFL
FIFO LOAD
Source
FIFO
Control
Length
Position
(EU)
(DN)
(EM)
FFU
FIFO UNLOAD
FIFO
Dest
Control
Length
Position
Output Instructions
PrefaceInstruction Set Reference Manual
4–30
LIFO Load (LFL) and LIFO Unload (LFU) 
LFL and LFU instructions are used in pairs. The LFL instruction loads words into a
user–created file called a LIFO stack. The LFU instruction unloads words from the
LIFO stack in the opposite order as they were entered.
Instruction parameters have been programmed in the LFL – LFU instruction pair
shown below.
(DN)
(EN)
(DN)
(EM)
LFL
LIFO LOAD
Source N7:10
LIFO #N7:12
Control R6:0
Length 34
Position 9
(EU)
(EM)
LFU
LIFO UNLOAD
LIFO #N7:12
Dest N7:11
Control R6:0
Length 34
Position 9
LFU instruction unloads data
from stack #N7:12 at position 8.
N7:12 0
N7:13 1
N7:14 2
3
4
5
6
7
8
9
33
34 words are allocated
for LIFO stack starting at
N7:12, ending at N7:45.
Loading and Unloading of Stack #N7:12
N7:10
N7:11
Position
Destination
Source
LFL instruction loads data into
stack #N7:12 at the next available
position, 9 in this case.
LFL–LFU Instruction Pair
N7:45
LFL Instruction Operation: When rung conditions change from false-to-true, the
LFL enable bit (EN) is set. This loads the contents of the source, N7:10, into the
stack element indicated by the position number, 9. The position value then
increments.
The LFL instruction loads an element at each false-to-true transition of the rung,